/** * Return user of current request in REST context * * Tries to get authenticcation scheme from cookie if any, fallback on token * authentication * * @throws \Rest_Exception_InvalidTokenException * @throws \User_StatusDeletedException * @throws \User_StatusSuspendedException * @throws \User_StatusInvalidException * @throws \User_StatusPendingException * @throws \User_PasswordExpiredException * * @return \PFUser */ public function getCurrentUser() { try { $user = $this->getUserFromCookie(); if ($user->isAnonymous()) { $user = $this->getUserFromToken(); $this->login_manager->validateAndSetCurrentUser($user); } return $user; } catch (NoAuthenticationHeadersException $exception) { return $this->user_manager->getUserAnonymous(); } }