public function accountSignout() { $ses = ApiSession::where('session_key', '=', $_GET['session_key'])->first(); $ses->delete(); $data = array('status' => 'ok', 'session' => null); return $data; }
/** * @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; }
/** * @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; }
/** * @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; }
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; } }
public static function getUser() { return ApiSession::get("user"); }
<?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 |--------------------------------------------------------------------------