/** * Authenticates a user. * The example implementation makes sure if the username and password * are both 'demo'. * In practical applications, this should be changed to authenticate * against some persistent user identity storage (e.g. database). * @return boolean whether authentication succeeds. */ public function authenticate() { $username = $this->username; $password = $this->password; $user = Authenticate::model()->find(array('condition' => "username='******'")); if (!empty($user)) { if ($password == $user->password) { $this->errorCode = self::ERROR_NONE; } else { $this->errorCode = self::ERROR_PASSWORD_INVALID; } } else { $this->errorCode = self::ERROR_USERNAME_INVALID; } return !$this->errorCode; }