public static function isLogged() { if (static::session()->{static::getInstance()->getPrimaryKey()}->exists() && static::session()->token->eq(Token::get(static::getSessionId()))) { return true; } return false; }
public function setElement($element) { $token = isset($element[$this->wrapper][0]) ? $element[$this->wrapper][0] : null; $controller = null; $method = null; if ($token) { if (preg_match("#^([a-z]+(\\\\([a-z]+))?)(" . Router::$__map['method']['separator'] . "([a-z]+))?\$#i", $token, $match)) { $controller = $match[1]; $method = $match[5]; } $token = Loader\Token::get($token); } $element['elements'] = array(self::createStatic('Input', Lib\Arr::extend(self::$element, array('attributes' => array('name' => 'token', 'value' => $token)))), self::createStatic('Input', Lib\Arr::extend(self::$element, array('attributes' => array('name' => 'controller', 'value' => $controller)))), self::createStatic('Input', Lib\Arr::extend(self::$element, array('attributes' => array('name' => 'method', 'value' => $method))))); return $element; }
public function signin() { if (Request::env('POST')->email->exists()) { if (Request::env('POST')->password->exists()) { if ($id = self::model()->exists(Request::env('POST')->email->val(), Request::env('POST')->password->val())) { Logger::getInstance()->info('Signin {admin}', array('admin' => Request::env('POST')->email->val())); self::model()->session()->id = $id; self::model()->session()->token = Token::get($id); $url = SJO_BASEHREF; if (preg_match('#^(\\./|/)#', Request::env('GET')->redirect->val())) { $url = Request::env('GET')->redirect->val(); } Http::redirect($url); } else { Alert::set(Lib\I18n::__('Les informations de connexion sont incorrects')); } } else { Alert::set(Lib\I18n::__('Veuillez renseigner votre mot de passe')); } } else { Alert::set(Lib\I18n::__('Veuillez renseigner votre identifiant')); } }