Example #1
0
 public function getUser()
 {
     if ($this->isGuest) {
         return false;
     }
     if ($this->_user === null) {
         $this->_user = DreamAdminUser::model()->findAllByPk($this->id);
     }
     return $this->_user;
 }
Example #2
0
 public function authenticate()
 {
     $username = strtolower($this->username);
     $user = DreamAdminUser::model()->find('LOWER(username)=?', array($username));
     $salt = md5(md5($this->password) . Yii::app()->params['TOKEN']);
     $password_hash = crypt($this->password, $salt);
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->password !== $password_hash) {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             $this->_id = $user->id;
             $this->username = $user->username;
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return $this->errorCode == self::ERROR_NONE;
 }