Beispiel #1
0
 /**
  * Store a new user in the database.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function store()
 {
     try {
         $user = $this->users->create($this->input());
         return $this->jsonResponse(['user' => $user]);
     } catch (ValidationException $e) {
         return $this->error($e->getMessageBag());
     }
 }
Beispiel #2
0
 /**
  * Attempt to reset a user's password.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function attemptReset()
 {
     $credentials = $this->input(['username']);
     $token = $this->input('token');
     $input = $this->input(['password', 'password_confirmation']);
     try {
         $this->users->resetPasswordForCredentials($credentials, $input, $token);
         return $this->success(['password reset, please log in']);
     } catch (ReminderException $e) {
         return $this->error(['password could not be reset']);
     }
 }
Beispiel #3
0
 /**
  * Check if password reminders are enabled.
  *
  * @return boolean
  */
 private function remindersEnabled()
 {
     return $this->users->remindersEnabled();
 }
Beispiel #4
0
 protected function canSwitchUser()
 {
     return $this->users->getCurrentUser()->hasAccess('superadmin');
 }