/** * Reset the password for the given token. * * @param array $credentials * @param \Closure $callback * * @return mixed */ public function reset(array $credentials, Closure $callback) { // If the responses from the validate method is not a user instance, we will // assume that it is a redirect and simply return it from this method and // the user is properly redirected having an error message on the post. $user = $this->validateReset($credentials); if (!$user instanceof CanResetPasswordContract) { return $user; } $pass = $credentials['password']; // Once we have called this callback, we will remove this token row from the // table and return the response from this callback so the user gets sent // to the destination given by the developers from the callback return. call_user_func($callback, $user, $pass); $this->tokens->delete($credentials['token']); return PasswordBrokerContract::PASSWORD_RESET; }
public function renew($email, $token, ResetPasswordRequest $resetPasswordRequest, UserRepositoryInterface $userRepository, TokenRepositoryInterface $tokenRepository) { $input = $resetPasswordRequest->all(); $user = $userRepository->findByEmail($email); if (!$user) { return $this->sendUnauthorized('Email not found.'); } if (!$tokenRepository->exists($user, $token)) { return $this->sendUnauthorized('Invalid token.'); } $user = $userRepository->changePassword($user, $input['password']); $tokenRepository->delete($token); return $this->sendSuccess([], 'Successfully reset your password. Now try logging in.'); }
/** * Delete the given password reset token. * * @param string $token * @return void */ public function deleteToken($token) { $this->tokens->delete($token); }