public static function createLogin($user, $createSession = true) { self::$me = $user; if ($createSession == true) { $_SESSION['userid'] = $user->id; } }
protected function assign() { $this->tpl->USER = User::me(); $this->tpl->url = $this->requestUrl(); $this->tpl->theme = Cfg::i()->theme_www; $this->tpl->path_forms = Cfg::i()->formroot; $this->requireJs(array("thirdparty/jQuery-2.1.4.min", "https://code.jquery.com/ui/1.11.4/jquery-ui.min.js", "thirdparty/bootstrap.min", "https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js", "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js", "plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min", "plugins/slimScroll/jquery.slimscroll.min", "app", "app.min", "thirdparty/form", "demo", "schedule")); $this->requireCss(array("https://fonts.googleapis.com/css?family=Fira+Sans", "https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css", "thirdparty/bootstrap.min", "thirdparty/_all-skins.min", "thirdparty/AdminLTE", "_main", "_schedule-table")); foreach ($this->tpl as $key => $value) { Tpl::i()->assign($key, $value); } }
public static function login($me = array()) { $me['IP'] = IP(); $me['FIRST'] = $me['LAST'] = now(); self::$me = $me; if (!self::$hash) { self::$hash = md5(microtime(true) . SECRET); } self::setCookie(); $pipeline = R::pipeline()->DEL(self::$prefix . self::$hash)->MULTI(); foreach (self::$me as $k => $v) { $pipeline->HSET(self::$prefix . self::$hash, $k, $v); } $pipeline->EXPIRE(self::$prefix . self::$hash, USER_SESSION_TIMEOUT); $pipeline->EXEC()->execute(); }
/** * This function checks the token of the client * Fails if token not found, or verifier not correct * Once again you __HAVE TO__ set the $provider->token_secret to the right value or the signature will fail * It's called by OAuthCheckRequest() unless the client is getting a request token * @param $provider * @return int */ public function checkToken($provider) { $this->token = OAuthToken::findByKey($provider->token); if (!$this->token->isHydrated()) { return OAUTH_TOKEN_REJECTED; } elseif ($this->token->get('type') == 1 && !$this->token->get('verified')) { return OAUTH_VERIFIER_INVALID; } else { if ($this->token->get('type') == 2) { /* if this is an access token we register the user to the provider for use in our api */ $this->user = $this->token->getUser(); User::$me = $this->user; } $provider->token_secret = $this->token->get('token_secret'); return OAUTH_OK; } }