/** * Get a User based on information in the request. Used by stateless authentication * systems like basic and digest auth. Powers Auth->user() in a stateless system. * * @param CakeRequest $request Request object. * @return mixed Either false or an array of user information * @throws StatelessAuthUnauthorizedException If there is no HTTP Authorization header present, or an unexpired User session could not be retrieve using it. */ public function getUser(CakeRequest $request) { $token = $this->getToken($request); $user = $this->UserModel->findForToken($token); $userModelName = $this->settings['userModel']; if (empty($user[$userModelName])) { throw new StatelessAuthUnauthorizedException('Missing, invalid or expired token present in request. Include an HTTP_AUTHORIZATION header, or please login to obtain a token.'); } return $user[$userModelName]; }