本文整理汇总了PHP中CWebUser::init方法的典型用法代码示例。如果您正苦于以下问题:PHP CWebUser::init方法的具体用法?PHP CWebUser::init怎么用?PHP CWebUser::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWebUser
的用法示例。
在下文中一共展示了CWebUser::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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')));
}
}
}
示例2: afterLogin
/**
* 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;
}
}
示例3: init
/**
* Инициализация компонента:
*
* @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();
}
示例4: init
public function init()
{
parent::init();
if (!$this->isGuest) {
/** @var $u User */
$u = User::model()->findByPk($this->id);
$this->_profile = $u;
}
}
示例5: init
/**
* @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()));
}
}
示例6: init
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();
}
示例7: 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();
}
}
}
示例8: init
/**
* 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();
}
}
示例9: 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));
}
}
示例10: testLoginLogout
/**
* @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());
}
示例11: init
/**
* Initializes the component.
*/
public function init()
{
parent::init();
//$this->setIsAdmin(in_array($this->name, Yii::app()->authManager->admins));
}
示例12: init
public function init()
{
parent::init();
}
示例13: init
/**
* Initializes the component.
*/
public function init()
{
parent::init();
$this->setIsAdmin(in_array($this->name, $this->admins));
}
示例14: init
public function init()
{
parent::init();
$this->module = Yii::app()->getModule('userAccount');
}
示例15: init
public function init()
{
parent::init();
$this->ini = new WebUserIni();
}