Devise\Users\Sessions\SessionsRepository::resetPassword PHP Метод

resetPassword() публичный Метод

Handle POST data from reset (change) password form
public resetPassword ( array $input ) : Response
$input array
Результат Response
    public function resetPassword($input)
    {
        $input = array_except($input, '_token');
        $resetUser = null;
        $response = $this->Framework->Password->reset($input, function ($user, $password) use(&$resetUser) {
            $user->password = $this->Hash->make($password);
            $user->save();
            $resetUser = $user;
        });
        switch ($response) {
            case \Password::INVALID_PASSWORD:
            case \Password::INVALID_TOKEN:
            case \Password::INVALID_USER:
                $this->message = 'There were validation errors.';
                $this->errors = $this->Lang->get($response);
                return false;
                break;
            case \Password::PASSWORD_RESET:
                $this->Auth->login($resetUser);
                $this->message = 'Password successfully changed.';
                return true;
                break;
        }
    }

Usage Example

Пример #1
0
 /**
  * Executes resetPassword method in SessionsRepository
  *
  * @param  array  $input
  * @return Response
  */
 public function requestResetPassword($input)
 {
     if ($this->SessionsRepository->resetPassword($input)) {
         return $this->Redirect->route('dvs-user-reset-password')->with('message-success', $this->SessionsRepository->message);
     }
     $urlWithToken = $this->URL->route('dvs-user-reset-password') . '?token=' . $input['token'];
     return $this->Redirect->to($urlWithToken)->withInput()->withErrors($this->SessionsRepository->errors)->with('message-errors', $this->SessionsRepository->message);
 }