middleware('guest:frontend'); } /** * Get the guard to be used during authentication. * * @return \Illuminate\Contracts\Auth\StatefulGuard */ protected function guard() { return Auth::guard('frontend'); } /** * Display the password reset view for the given token. * * If no token is present, display the link request form. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function showResetForm(Request $request) { $token = $request->route()->parameter('token'); return view('fo.auth.passwords.reset')->with( ['token' => $token, 'email' => $request->email] ); } /** * Reset the given user's password. * * @param mixed $customer * @param mixed $password * @return void * @throws \Illuminate\Validation\ValidationException If something goes wrong. */ protected function resetPassword($customer, $password) { /** @var \LDC\LDCCRM\CrmApiV4 */ $crm = app('crmAPI'); try { if (!($crmCustomer = $crm->getCustomer($customer->hashcode))) { throw ValidationException::withMessages([ 'error' => 'Changement impossible, compte inexistant.' ]); } $crmCustomer->password = $password; $crmCustomer->save(); } catch (\TypeError | CrmException | ApiErrorException $e) { report($e); throw ValidationException::withMessages([ 'error' => 'Une erreur est survenue, merci de réessayer ultérieurement.' ]); } catch (ExceptionsValidationException $e) { throw ValidationException::withMessages([ 'error' => $e->getMessage() ]); } $customer->setRememberToken(Str::random(60)); $customer->save(); event(new PasswordReset($customer)); $this->guard()->login($customer); } /** * Get the post register / login redirect path. * * @return string */ public function redirectPath() { return response()->redirectToRoute('fo.customer.dashboard')->getTargetUrl(); } /** * Get the broker to be used during password reset. * * @return \Illuminate\Contracts\Auth\PasswordBroker */ public function broker() { return Password::broker('customers'); } }