public function run()
 {
     $token = $this->request->getPar('at');
     $session = new Session();
     $session->setAccessToken($token);
     $result = $session->read();
     if ($result === null) {
         throw new GraphException('Access token not valid', 404);
     }
     if ($result->getEnabled() === false) {
         throw new GraphException('Session is closed', 400);
     }
     $this->sendModel($result);
 }
Example #2
0
 public function run()
 {
     $accessToken = $this->request->getPar('at');
     if ($accessToken === null) {
         $accessToken = $this->request->getHeader('access-token');
     }
     if ($accessToken === null) {
         throw new GraphException('access token not sent', 400);
     }
     $session = new Session();
     $session->setAccessToken($accessToken);
     $readed = $session->read();
     if ($readed === null) {
         throw new GraphException('Access token not valid', 404);
     }
     if ($readed->getEnabled() === false) {
         throw new GraphException('Session already closed', 400);
     }
     $readed->setEnabled(false);
     $readed->update();
     $this->sendMessage('Logout successful');
 }
Example #3
0
 public function __construct()
 {
     $this->session = Session::getSession();
 }
Example #4
0
 /**
  * @return bool
  * @throws \Database\Exception
  * @throws \Kohana_Exception
  */
 public static function destroy()
 {
     if (true == ($userSession = self::Check())) {
         \Session::instance()->delete('user_id');
         \Cookie::delete('user_token');
         if (is_object($userSession)) {
             return $userSession->deleteAll();
         } else {
             return $userSession;
         }
     } else {
         \Session::instance()->delete('user_id');
         \Cookie::delete('user_token');
         //throw new \Kohana_Exception('Error destroy session');
         return false;
     }
 }
Example #5
0
 public function getResponseStruct()
 {
     $session = new Session();
     return ['User' => $session->getStruct()];
 }