smsService = $smsService; $this->authService = $authService; $this->emailService = $emailService; } public function passwordRequest() { return view('app.auth.password_request', ['title'=>'重置密码']); } public function passwordRequestPost(ResetPasswordValidatorRequest $request) { if ($request->type == 'mobile') { if (!$this->smsService->checkAuthSms($request->mobile, Smser::TEMPLATE_AUTH_CHECK, $request->mobile_vcode)) { return $this->sendErrorResponse("短信验证码不对"); } $token=$this->authService->resetPasswordToken($request->all()); return $this->sendSuccessResponse(['url'=>route('password.reset', ['token'=>$token])]); } elseif ($request->type == 'email') { $token=$this->authService->resetPasswordToken($request->all()); $this->emailService->setCallback('App\Services\Auth\AuthService', 'sendEmailHook', [$request->email, $token]) ->sendAuthMail($request->email, EmailService::TEMPLATE_PASSWORD_RESET); return $this->sendSuccessResponse(['url'=>route('password.reset', ['token'=>$request->email])]); } } public function passwordReset($token) { $data['token']=$token; $data['title']="重置密码"; if (validator_check($token, 'email')) { return view('app.auth.password_reset_email', $data); } if (!$data=$this->authService->checkResetPasswordToken($token)) { throw new ResponseException("who are you?", [], 404); } $data['token']=$token; $data['title']="重置密码"; return view('app.auth.password_reset', $data); } public function passwordResetPost(ResetPasswordValidatorRequest $request, $token) { if (!$data=$this->authService->checkResetPasswordToken($token)) { throw new ResponseException("who are you?", [], 404); } $utype=$this->authService->resetPassword($token, $request->password); $login_url =$utype==1?route('login.company'):route('login'); return view('app.auth.password_reset_success', ['login_url'=>$login_url]); } }