/** * Update the logged in user's profile. * * @return \Illuminate\Http\JsonResponse */ public function updateProfile() { try { $this->users->updateCurrentProfile($this->input()); return $this->jsonResponse(['user' => $this->users->getCurrentUser()]); } catch (ValidationException $e) { return $this->error($e->getMessageBag()); } }
/** * Attempt to log a user in. * * @return \Illuminate\Http\JsonResponse */ public function attemptLogin() { $credentials = ['username' => $this->input('username'), 'password' => $this->input('password')]; $remember = Config::get('c::login-remember') && $this->input('remember_me'); try { $this->users->login($credentials, $remember); $user = $this->users->getCurrentUser(); $data = ['status' => 'logged in', 'user' => $user]; return $this->jsonResponse($data, 200); } catch (AuthenticationException $e) { if ($this->debug) { throw $e; } return $this->status('login failed', 401); } }
protected function canSwitchUser() { return $this->users->getCurrentUser()->hasAccess('superadmin'); }