Exemplo n.º 1
0
 /**
  *	Retrieve User From Cookie
  *	@return AuthedUserInterface
  */
 public function retrieveUserFromCookie()
 {
     if (!Cookie::exists(self::LOGIN_COOKIE_KEY)) {
         return NULL;
     }
     try {
         list($username, $data) = array_pad(explode('|', Encryption::decrypt(base64_decode(Cookie::get(self::LOGIN_COOKIE_KEY))), 2), 2, null);
         list($id, $security, $userInfo) = array_pad(explode('|', Encryption::decrypt($data), 3), 3, null);
         $userInfo = json_decode($userInfo);
         $user = new StdAuthedUser($id, $username, $userInfo);
         if ($security !== $this->cookieHash($user)) {
             $user = NULL;
         }
     } catch (\Exception $e) {
         $user = NULL;
     }
     return $user;
 }
Exemplo n.º 2
0
 /**
  *	Logout
  *	@return BOOL
  */
 public function logout()
 {
     if (!Cookie::delete(self::LOGIN_COOKIE_KEY)) {
         \pre_r("Failed to delete cookie");
     }
 }