love_php/app/Http/Controllers/Auth/ForgotPasswordController.php
2026-04-02 09:20:51 +08:00

57 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use App\Models\User;
use App\Contracts\UserContract;
use Illuminate\Http\Request;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
protected $sms;
protected $userCon;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct(UserContract $userCon)
{
$this->userCon = $userCon;
$this->middleware('guest');
}
public function appPaaswordReset(Request $request)
{
try {
$mobile = $request->mobile;
$password = $request->password;
$user = User::where('mobile', $mobile)->select('id', 'nickname', 'sex', 'type','belief','mobile', 'app_avatar','hidden_profile', 'live_match_maker', 'is_approved', 'industry', 'industry_sub', 'photo')->first();
if (empty($user)) {
return $this->failure('该手机号用户不存在');
}
$user->password = bcrypt($password);
$user->save();
$user = $this->userCon->otherAppLoginParam($request, $user, $has_mobile = 1);
return $this->success('ok', $user);
} catch (\Exception $e) {
return $this->failure('重置密码失败');
}
}
}