本文整理匯總了PHP中Authenticate::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP Authenticate::model方法的具體用法?PHP Authenticate::model怎麽用?PHP Authenticate::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Authenticate
的用法示例。
在下文中一共展示了Authenticate::model方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: authenticate
/**
* 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='{$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;
}