コード例 #1
0
 /**
  * Processes the password update.
  *
  * @param string|int $id
  * @param string|int $key
  *
  * @return \Illuminate\Http\JsonResponse|mixed
  */
 public function postReset($id, $key)
 {
     if ($this->passwordValidator->passes()) {
         $user = $this->sentry->findUserById($id);
         if ($user->checkResetPasswordCode($key)) {
             if ($user->attemptResetPassword($key, $this->input('password'))) {
                 $link = link_to_route('maintenance.login', 'login');
                 $this->message = "Successfully updated your password, you can now {$link}.";
                 $this->messageType = 'success';
                 $this->redirect = route('maintenance.login');
             } else {
                 $this->message = 'You have already updated your password.';
                 $this->messageType = 'danger';
                 $this->redirect = route('maintenance.login');
             }
         } else {
             $this->message = 'You have already reset your password.';
             $this->messageType = 'danger';
             $this->redirect = route('maintenance.login');
         }
     } else {
         $this->errors = $this->passwordValidator->getErrors();
         $this->redirect = route('maintenance.login');
     }
     return $this->response();
 }
コード例 #2
0
 /**
  * Updates the specified users password.
  *
  * @param $id
  *
  * @return \Illuminate\Http\JsonResponse|mixed
  */
 public function update($id)
 {
     if ($this->passwordValidator->passes()) {
         if ($this->sentry->updatePasswordById($id, $this->input('password'))) {
             $this->message = 'Successfully updated password';
             $this->messageType = 'success';
             $this->redirect = routeBack('maintenance.admin.users.show', [$id]);
         } else {
             $this->message = 'There was an issue resseting this users password. Please try again';
             $this->messageType = 'danger';
             $this->redirect = routeBack('maintenance.admin.users.show', [$id]);
         }
     } else {
         $this->errors = $this->passwordValidator->getErrors();
         $this->redirect = route('maintenance.admin.users.show', [$id]);
     }
     return $this->response();
 }