public function accountSignout()
 {
     $ses = ApiSession::where('session_key', '=', $_GET['session_key'])->first();
     $ses->delete();
     $data = array('status' => 'ok', 'session' => null);
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * @param Member $user
  * @return ApiSession
  */
 public static function createSession($user)
 {
     // create session
     $session = ApiSession::create();
     $session->User = $user;
     $session->Token = JwtAuth::generate_token($user);
     return $session;
 }
Ejemplo n.º 3
0
 /**
  * @param \Member $user
  * @return ApiSession
  */
 public static function createSession($user)
 {
     $user->logIn();
     /** @var \Member $user */
     $user = \DataObject::get(\Config::inst()->get('BaseRestController', 'Owner'))->byID($user->ID);
     // create session
     $session = ApiSession::create();
     $session->User = $user;
     $session->Token = AuthFactory::generate_token($user);
     return $session;
 }
Ejemplo n.º 4
0
 /**
  * @param \Member $user
  * @return ApiSession
  */
 public static function createSession($user)
 {
     // create session
     $session = ApiSession::create();
     $session->User = $user;
     $session->Token = AuthFactory::generate_token($user);
     // save session
     $cache = \SS_Cache::factory('rest_cache');
     $cache->save(json_encode(['token' => $session->Token, 'user' => $session->User->ID]), $session->Token);
     return $session;
 }
Ejemplo n.º 5
0
 public function gc($maxlifetime)
 {
     foreach (glob(session_save_path()) as $file) {
         if (filemtime($file) + $maxlifetime < time()) {
             $sessionId = XXXXX;
             ApiSession::delete($sessionId);
             unlink($file);
         }
     }
     return TRUE;
 }
 public static function authenticate($email, $password)
 {
     $authenticator = new MemberAuthenticator();
     if ($user = $authenticator->authenticate(['Password' => $password, 'Email' => $email])) {
         // create session
         $session = ApiSession::create();
         $session->User = $user;
         $session->Token = JwtAuth::generate_token($user);
         return $session;
     }
 }
 public static function authenticate($email, $password)
 {
     $authenticator = new MemberAuthenticator();
     if ($user = $authenticator->authenticate(['Password' => $password, 'Email' => $email])) {
         // create session
         $session = ApiSession::create();
         $session->User = $user;
         $session->Token = AuthFactory::generate_token($user);
         // save session
         $cache = SS_Cache::factory('rest_cache');
         $cache->save(json_encode(['token' => $session->Token, 'user' => $session->User->ID]), $session->Token);
         return $session;
     }
 }
 public static function authenticate($email, $password)
 {
     // auth
     $authenticator = new \MemberAuthenticator();
     if ($user = $authenticator->authenticate(['Password' => $password, 'Email' => $email])) {
         $user->logIn();
         $user = DataObject::get(Config::inst()->get('BaseRestController', 'Owner'))->byID($user->ID);
         // create session
         $session = ApiSession::create();
         $session->User = $user;
         $session->Token = AuthFactory::generate_token($user);
         return $session;
     }
 }
Ejemplo n.º 9
0
 public static function getUser()
 {
     return ApiSession::get("user");
 }
Ejemplo n.º 10
0
<?php

/* Api - Require Session Key */
Route::filter('sessionkey', function () {
    if (isset($_GET['session_key']) && sizeof(ApiSession::where('session_key', '=', $_GET['session_key'])->get()) == 1) {
    } elseif (isset($_POST['session_key']) && sizeof(ApiSession::where('session_key', '=', $_POST['session_key'])->get()) == 1) {
    } else {
        $data = array('status' => 'failed', 'error_msg' => 'Missing valid session key');
        return $data;
    }
});
/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    //
});
App::after(function ($request, $response) {
    //
});
/*
|--------------------------------------------------------------------------
| Authentication Filters
|--------------------------------------------------------------------------