middleware('guest:club'); } /** * Get the guard to be used during authentication. */ protected function guard(): StatefulGuard { return Auth::guard('club'); } /** * Display the password reset view for the given token. * * If no token is present, display the link request form. */ public function showResetForm(Request $request): View { $token = $request->route()->parameter('token'); return view('club.auth.passwords.reset')->with([ 'token' => $token, 'email' => $request->email, ]); } /** * Reset the given user's password. * * @throws \Illuminate\Validation\ValidationException If something goes wrong. */ protected function resetPassword(Customer $customer, string $password): void { /** @var \LDC\LDCCRM\CrmApiV4 */ $crm = app('crmAPI'); try { if (! ($crmCustomer = $crm->getCustomer($customer->hashcode))) { throw ValidationException::withMessages([ 'error' => trans('Changement impossible, compte inexistant.'), ]); } $crmCustomer->password = $password; $crmCustomer->save(); } catch (\TypeError | CrmException | ApiErrorException $e) { report($e); throw ValidationException::withMessages([ 'error' => trans('Une erreur est survenue, merci de réessayer ultérieurement.'), ]); } catch (ExceptionsValidationException $e) { throw ValidationException::withMessages([ 'password' => $e->getMessage(), ]); } $customer->setRememberToken(Str::random(60)); $customer->saveOrFail(); event(new CustomerPasswordReset($customer, $customer->api_data->firstname)); $this->guard()->login($customer); Session::flash('success', trans('Votre mot de passe à bien été réinitialisé, vous êtes à présent connecté.')); } /** * Get the post register / login redirect path. */ public function redirectPath(): string { return $this->authLoggedRedirectPath(); } /** * Get the broker to be used during password reset. */ public function broker(): PasswordBroker { return Password::broker('customers'); } }