/** * Trigger the actual sending of the email. * * @param Request $request * @param UserRepositoryInterface $users * @param AccountManager $manager * @return */ public function store(Request $request, UserRepositoryInterface $users, AccountManager $manager) { $user = $users->findUserByEmail($request->get('email')); if ($user) { $this->dispatch(new SendConfirmationEmail($user)); } return redirect()->to(store_route('store.auth.signin.index'))->withSuccess(Lang::get('users::front.request-handled')); }
/** * @param UserRepositoryInterface $users * @param Hasher $hasher * @return mixed|string * @throws \Exception */ public function handle(UserRepositoryInterface $users, hasher $hasher) { $user = $users->findUserByEmail($this->email); if ($user) { if (!$this->validToken($user)) { return 'invalid token'; } if ($this->equalPasswords()) { $user->password = $hasher->make($this->password); $user->reset_token_id = null; $user->save(); $this->token->delete(); return $user; } } }
/** * @param UserRepositoryInterface $users * @param Guard $guard * @return mixed * @throws \Exception */ public function handle(UserRepositoryInterface $users, Guard $guard) { $user = $users->findUserByConfirmationToken($this->token->id); if ($user) { if (!$user->confirmed) { $user->confirmed = 1; } //only reset the token if we actually found a user $user->confirmation_token_id = null; $user->save(); $guard->loginUsingId($user->id); } //token can always be deleted $this->token->delete(); return $user; }
/** * @param Guard $auth * @param Throttler $throttler * @param UserRepositoryInterface $users * @return bool|\Illuminate\Contracts\Auth\Authenticatable|null|string */ public function handle(Guard $auth, Throttler $throttler, UserRepositoryInterface $users) { $credentials = $this->getCredentialsForAttempt(); //disallow to many attempts in to short time interval $email = $credentials['email']; if ($throttler->allows($email)) { if ($auth->attempt($credentials, $this->remember_me)) { return $auth->user(); } else { $user = $users->findUserByEmail($email); //do not throttle when the user is still unconfirmed, so we can display a message if (!$user || $user->confirmed == 1) { $throttler->throttle($email); } else { return 'unconfirmed'; } } } return false; }
/** * @param ThemeMailer $mail * @param TokenRepositoryInterface $tokens * @param Translator $lang * @param UserRepositoryInterface $users * @throws Exception */ public function handle(ThemeMailer $mail, TokenRepositoryInterface $tokens, Translator $lang, UserRepositoryInterface $users) { try { $user = $users->findUserByEmail($this->email); if ($user) { $token = $tokens->createNewToken(Token::TYPE_RESET, $this->email); $user->resetToken()->associate($token); $user->save(); $subject = $lang->get('users::emails.reset-password.subject'); $data = array_merge($this->baseData(), ['user' => $user, 'token' => $token, 'email_to' => $this->email]); $send = $mail->send('users::emails.reset-password', $data, $subject); if ($send) { $this->delete(); } } } catch (Exception $e) { $this->release(); throw $e; } }