1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| classUserIdentityextendsCUserIdentity {
private$_id;
publicfunctionauthenticate() {
$record=User::model()->findByAttributes(array('username'=>$this->username));
if($record===null) $this->errorCode=self::ERROR_USERNAME_INVALID; elseif($record->password!==md5($this->password)) $this->errorCode=self::ERROR_PASSWORD_INVALID; else{ $this->_id=$record->id; $this->setState('title',$record->title); $this->errorCode=self::ERROR_NONE; }
return!$this->errorCode; }
publicfunctiongetId() { return$this->_id; } }
|