コード例 #1
0
ファイル: DaWebUser.php プロジェクト: kot-ezhva/ygin
 /**
  * Logs in a user.
  *
  * The user identity information will be saved in storage that is
  * persistent during the user session. By default, the storage is simply
  * the session storage. If the duration parameter is greater than 0,
  * a cookie will be sent to prepare for cookie-based login in future.
  *
  * Note, you have to set {@link allowAutoLogin} to true
  * if you want to allow user to be authenticated based on the cookie information.
  *
  * @param IUserIdentity $identity the user identity (which should already be authenticated)
  * @param integer $duration number of seconds that the user can remain in logged-in status. Defaults to 0, meaning login till the user closes the browser.
  * If greater than 0, cookie-based login will be used. In this case, {@link allowAutoLogin}
  * must be set true, otherwise an exception will be thrown.
  * @return boolean whether the user is logged in
  */
 public function login($identity, $duration = 0)
 {
     $id = $identity->getId();
     $states = $identity->getPersistentStates();
     if ($this->beforeLogin($id, $states, false)) {
         $this->changeIdentity($id, $identity->getName(), $states);
         //      if($duration>0)
         //      {
         if ($this->allowAutoLogin) {
             $this->saveToCookie($duration);
         } else {
             throw new CException(Yii::t('yii', '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.', array('{class}' => get_class($this))));
         }
         //      }
         $this->afterLogin(false);
     }
     return !$this->getIsGuest();
 }
コード例 #2
0
ファイル: WebUser.php プロジェクト: jankichaudhari/yii-site
 /**
  * @param IUserIdentity $identity
  * @param int           $duration
  * @return bool
  */
 public function login($identity, $duration = 0)
 {
     $this->setState("__branchId", $identity->getBranchId());
     $this->setState("__scope", $identity->getScope());
     $this->setState("__roles", $identity->getRoles());
     $this->setState("__userData", $identity->getUserData());
     return parent::login($identity, $duration);
 }
コード例 #3
0
 /**
  * Logs in a user.
  *
  * The user identity information will be saved in storage that is
  * persistent during the user session. By default, the storage is simply
  * the session storage. If the duration parameter is greater than 0,
  * a cookie will be sent to prepare for cookie-based login in future.
  *
  * Note, you have to set {@link allowAutoLogin} to true
  * if you want to allow user to be authenticated based on the cookie information.
  *
  * @param IUserIdentity $identity the user identity (which should already be authenticated)
  * @param integer $duration number of seconds that the user can remain in logged-in status. Defaults to 0, meaning login till the user closes the browser.
  * If greater than 0, cookie-based login will be used. In this case, {@link allowAutoLogin}
  * must be set true, otherwise an exception will be thrown.
  * @return boolean whether the user is logged in
  */
 public function login($identity, $duration = 0)
 {
     $id = $identity->getId();
     $states = $identity->getPersistentStates();
     if ($this->beforeLogin($id, $states, false)) {
         $this->changeIdentity($id, $identity->getName(), $states);
         if ($duration > 0) {
             if ($this->allowAutoLogin) {
                 $this->saveToCookie($duration);
             } else {
                 throw new CException(Yii::t('yii', '{class}.allowAutoLogin must be set true in order to use cookie-based authentication.', array('{class}' => get_class($this))));
             }
         }
         if ($this->absoluteAuthTimeout) {
             $this->setState(self::AUTH_ABSOLUTE_TIMEOUT_VAR, time() + $this->absoluteAuthTimeout);
         }
         $this->afterLogin(false);
     }
     return !$this->getIsGuest();
 }
コード例 #4
0
ファイル: YWebUser.php プロジェクト: kuzmina-mariya/4seasons
 /**
  * @param  IUserIdentity $identity
  * @param  int $duration
  * @return bool
  */
 public function login($identity, $duration = 0)
 {
     if ($duration) {
         //создать токен
         $token = Yii::app()->userManager->tokenStorage->createCookieAuthToken($this->getProfile(), $duration);
         $identity->setState($this->authToken, $token->token);
     }
     return parent::login($identity, $duration);
 }