public function init() { parent::init(); //Normalize user IP $this->ip = $_SERVER['REMOTE_ADDR']; $this->ip = preg_replace('/^[^\\d]*/', '', $this->ip); if (!$this->getIsGuest()) { if (md5($this->model->password) != $this->getState('token')) { Yii::log('Invalid cookie token for ' . $this->name . '. Logging out.'); $this->logout(true); Yii::app()->getRequest()->redirect(CHtml::normalizeUrl(array('/site'))); } $stateIp = $this->getState('ip'); if ($this->ip != $stateIp && $stateIp != 'ignore') { Yii::log('Invalid cookie IP for ' . $this->name . '. Logging out.'); $this->logout(true); Yii::app()->getRequest()->redirect(CHtml::normalizeUrl(array('/site'))); } if (@Yii::app()->params['installer'] != 'show' && isset($this->model->lang) && preg_match('/^[a-zA-Z_]+$/', $this->model->lang)) { Yii::app()->language = $this->model->lang; } } if ($this->isSuperuser() && @strlen(Yii::app()->params['admin_ips'])) { if (!$this->checkIp(Yii::app()->params['admin_ips'])) { Yii::log('Superuser access denied for ' . $this->name . ' (IP ' . $this->ip . ')'); $this->logout(true); Yii::app()->getRequest()->redirect(CHtml::normalizeUrl(array('/site'))); } } }
/** * Actions to be taken after logging in. * Overloads the parent method in order to mark superusers. * @param boolean whether the login is based on cookie. */ public function afterLogin($fromCookie) { parent::init($fromCookie); // Mark the user as a superuser if necessary. if (Rights::getAuthorizer()->isSuperuser($this->getId()) === true) { $this->isSuperuser = true; } }
/** * Инициализация компонента: * * @return parent::init() **/ public function init() { $this->allowAutoLogin = true; $this->authTimeout = 24 * 2600; $this->autoRenewCookie = true; $this->loginUrl = Yii::app()->createUrl($this->loginUrl); return parent::init(); }
public function init() { parent::init(); if (!$this->isGuest) { /** @var $u User */ $u = User::model()->findByPk($this->id); $this->_profile = $u; } }
/** * @inheritDoc */ public function init() { parent::init(); if (!$this->isGuest) { // Note that saveAttributes can return false if the account is active twice the same second // because no attributes are updated, therefore we cannot throw an exception if save fails. $this->loadAccount()->saveAttributes(array('lastActiveAt' => Helper::sqlNow())); } }
public function init() { $account = Ibos::app()->setting->get("setting/account"); $this->account = $account; $isAutologin = MainUtil::getCookie("autologin"); if (!$isAutologin) { $this->authTimeout = (int) $account["timeout"] * 60; } parent::init(); }
public function init() { parent::init(); if ($this->getIsGuest() === FALSE) { // Если юзер залогинен то обновляю его инфу $this->_user = Users::model()->with('profile')->find('auth_hash = :auth_hash', array('auth_hash' => $this->getState('auth_hash'))); if (!$this->_user) { $this->logout(); } } }
/** * Initializes the application component. * * This method will determine how long user sessions are configured to last, and whether the current request * has requested to not extend the current user session, before calling {@link \CWebUser::init()}. * * @return null */ public function init() { if (!craft()->isConsole()) { // Set the authTimeout based on whether the current identity was created with "Remember Me" checked. $data = $this->getIdentityCookieValue(); $this->authTimeout = craft()->config->getUserSessionDuration($data ? $data[3] : false); // Should we skip auto login and cookie renewal? $this->_dontExtendSession = !$this->shouldExtendSession(); $this->autoRenewCookie = !$this->_dontExtendSession; parent::init(); } }
/** * Initialisation Method * * @access public * @return void */ public function init() { parent::init(); // Raise an "onEndUser" event. $this->onStartUser(new Event($this)); // Is the user logged in or not? if (!$this->getState('isGuest')) { // Load the database model for the currently logged in user so we can use their information throughout // the request. $this->user = User::model()->findByPk($this->getState('id')); // Raise an "onAuthenticated" event; specifying that the end-user is logged in. $this->onAuthenticated(new Event($this)); } else { // Raise an "onGuest" event; specifying that the end-user is not logged in. $this->onGuest(new Event($this)); } }
/** * @runInSeparateProcess * @outputBuffering enabled * @dataProvider booleanProvider */ public function testLoginLogout($destroySession) { $identity = new CUserIdentity('testUser', 'testPassword'); $user = new CWebUser(); $user->init(); // be guest before login $this->assertTrue($user->isGuest); // do a login $this->assertTrue($user->login($identity)); // don't be guest after login $this->assertFalse($user->isGuest); $this->assertEquals('testUser', $user->getId()); $this->assertEquals('testUser', $user->getName()); $user->logout($destroySession); // be guest after logout $this->assertNull($user->getId()); $this->assertEquals($user->guestName, $user->getName()); }
/** * Initializes the component. */ public function init() { parent::init(); //$this->setIsAdmin(in_array($this->name, Yii::app()->authManager->admins)); }
public function init() { parent::init(); }
/** * Initializes the component. */ public function init() { parent::init(); $this->setIsAdmin(in_array($this->name, $this->admins)); }
public function init() { parent::init(); $this->module = Yii::app()->getModule('userAccount'); }
public function init() { parent::init(); $this->ini = new WebUserIni(); }
/** * Initializes the application component. * This method overrides the parent implementation by starting session, * performing cookie-based authentication if enabled, and updating the flash variables. */ public function init() { if (get_class(Yii::app()) != 'CConsoleApplication') { parent::init(); } }
public function init() { $conf = Yii::app()->session->cookieParams; $this->identityCookie = array('path' => "/", 'domain' => "192.168.42.89"); parent::init(); }
public function init() { parent::init(); $this->loginUrl = Yii::app()->request->baseUrl . '/login?message=1'; }
public function init() { parent::init(); // Get the active entry id from session. $this->_activeEntryId = $this->getState('activeEntryId'); }
public function init() { parent::init(); $this->updateLastActiveAt(); }