/**
  * perform the login action
  * @param CUserIdentity $identity
  * @param int $duration
  * @see CWebUser::login()
  */
 public function login($identity, $duration = 0)
 {
     $id = $identity->getId();
     $states = $identity->getPersistentStates();
     if ($this->beforeLogin($id, $states, false)) {
         $this->UGChangeIdentity($id, $identity->getName(), $identity->getGroup(), $identity->getGroupName(), $identity->getLevel(), $identity->getAccessRules(), $identity->getHome(), $identity->getRecovery(), $identity->getProfile(), $states);
         $this->profileLoad();
         if ($duration > 0) {
             if ($this->allowAutoLogin) {
                 $this->saveToCookie($duration);
             } else {
                 throw new CException(Yii::t('userGroupsModule.admin', '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.', array('{class}' => get_class($this))));
             }
         }
         $this->afterLogin(false);
     }
 }
示例#2
0
 /**
  * Login function
  *
  * @param CUserIdentity $identity user identity
  * @param int           $duration duration of cookie
  *
  * @return void
  */
 public function login($identity, $duration)
 {
     $userId = $identity->getId();
     $name = $identity->getName();
     // @todo Implement an ability to get/set persistent states
     $states = $identity->getPersistentStates();
     if ($this->beforeLogin($userId, $states, false)) {
         $cookieData = array('id' => $userId, 'name' => $name);
         $this->_userData = $cookieData;
         $this->setCookie($cookieData, $duration);
         $this->isGuest = false;
         $this->afterLogin(false);
     }
 }