public function __construct() { // Note: it is not recommended to call Auth_Sprig::instance() for both global and siteauth, since that will return a singleton everytime, and this will get conflicts between globalauth and siteauth, if they are used at the same time // Manually loading the config and creating a new Auth_Sprig like // $conf = Kohana::config("auth"); // $inst = new Auth_Sprig($conf); // Does also not work, since this will (assumably) call the new Auth() twice, // where somewhere the salt_pattern gets rewritten to an array, causing an error the next time the Auth() is generated $this->_auth = Auth_Sprig::instance(); $this->_auth->user_model($this->_user_model); $this->_auth->token_model($this->_token_model); $this->session = Session::instance(); if ($this->logged_in() or $this->auto_login() == TRUE) { // Logged in $this->user = $this->get_user(); // Set cache-addendum // TODO: Wi3::$cache->page_addendums["wi3_login_userid"] = $this->user->id; $this->session->set("userid", $this->user->id); } }
/** * Gets the currently logged in user from the session. * Returns FALSE if no user is currently logged in. * * @return mixed */ public function get_user() { $user = parent::get_user(); if ($user !== FALSE) { return $user; } if ($fb_uid = FB::get_loggedin_user()) { $user = Sprig::factory('User', array('fb_uid' => $fb_uid))->load(); if (is_object($user) and $user->loaded()) { $this->_user = $user; return $this->_user; } } return FALSE; }