Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * UserIdentity represents the data needed to identity a user.
- * It contains the authentication method that checks if the provided
- * data can identity the user.
- */
- class UserIdentity extends CUserIdentity
- {
- private $_id;
- /**
- * Authenticates a user using the User data model.
- * @return boolean whether authentication succeeds.
- */
- public function authenticate()
- {
- $user=User::model()->findByAttributes(array('username'=>$this->username));
- $pass1=$user->password;
- $pass2=$this->password;
- $n=strlen($pass1);
- if($user===null)
- {
- $this->errorCode=self::ERROR_USERNAME_INVALID;
- }
- else
- {
- if(strncmp($pass1,$pass2,$n)!==0)
- {
- $this->errorCode=self::ERROR_PASSWORD_INVALID;
- }
- else
- { Yii::log('length: '.$n,'trace');
- $this->_id = $user->id;
- Yii::log('id: '.$this->_id,'trace');
- $this->errorCode == self::ERROR_NONE;
- Yii::log('errorCode: '.$this->errorCode,'trace');
- }
- }
- Yii::log('errorCode: '.$this->errorCode,'trace');
- return !$this->errorCode;
- }
- public function getId()
- {
- return $this->_id;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement