本文整理汇总了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;
}