protected function beforeLogin($id, $states, $fromCookie)
 {
     if ($fromCookie) {
         //the cookie isn't here, so we refuse the login
         if (!isset($states[UserIdentity::LOGIN_TOKEN])) {
             return false;
         }
         $model = Users::model()->findByPk($id);
         if ($model == null) {
             return false;
         }
         //check if cookie is correct
         $cookieLoginToken = $states[UserIdentity::LOGIN_TOKEN];
         if (!isset($cookieLoginToken) || $cookieLoginToken != $model->logintoken) {
             return false;
         }
         if (!$model->activated || $model->blocked || $model->deleted) {
             //user deleted
             return false;
         }
     }
     if (!parent::beforeLogin($id, $states, $fromCookie)) {
         return false;
     }
     return true;
 }
Exemple #2
0
 protected function beforeLogin($id, $states, $fromCookie)
 {
     parent::beforeLogin($id, $states, $fromCookie);
     $model = new UserLoginStats();
     $model->attributes = array('user_id' => $id, 'ip' => ip2long(Yii::app()->request->getUserHostAddress()));
     $model->save();
     return true;
 }
Exemple #3
0
 protected function beforeLogin($id, $states, $fromCookie)
 {
     return parent::beforeLogin($id, $states, $fromCookie);
 }
Exemple #4
0
 /**
  * @param  mixed $id
  * @param  array $states
  * @param  bool $fromCookie
  * @return bool
  */
 public function beforeLogin($id, $states, $fromCookie)
 {
     if (!$fromCookie) {
         return parent::beforeLogin($id, $states, $fromCookie);
     }
     //проверить токен авторизации
     $token = isset($states[$this->authToken]) ? $states[$this->authToken] : null;
     if (empty($token)) {
         return false;
     }
     $model = Yii::app()->userManager->tokenStorage->get($token, UserToken::TYPE_COOKIE_AUTH);
     if (null === $model) {
         return false;
     }
     return true;
 }