同时修改项目下protected/components下的UserIdentity.php
<?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
{
/**
* 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()
{
/*
$users=array(
// username => password
'demo'=>'demo',
'admin'=>'admin',
);
if(!isset($users[$this->username]))
$this->errorCode=self::ERROR_USERNAME_INVALID;
elseif($users[$this->username]!==$this->password)
$this->errorCode=self::ERROR_PASSWORD_INVALID;
else
$this->errorCode=self::ERROR_NONE;
return !$this->errorCode;
*/
$user_model = Auth::model()->find('a_account=:name',array(':name'=>$this->username));
if($user_model === null){
$this -> errorCode = self::ERROR_USERNAME_INVALID;
return false;
} else if ($user_model->a_password !== md5($this -> password)){
$this->errorCode=self::ERROR_PASSWORD_INVALID;
return false;
} else {
$this->errorCode=self::ERROR_NONE;
return true;
}
}
}
更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
Laravel下生成验证码的类这篇文章主要为大家详细介绍了Laravel下生成验证码的类,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
PHP实现验证码校验功能这篇文章主要为大家详细介绍了PHP实现验证码校验功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
php利用云片网实现短信验证码功能的示例代码这篇文章主要介绍了php利用云片网实现短信验证码功能的示例代码,小编觉得挺不错的,现在分享给大家,也给大家
PHP验证码类文件及调用方式代码详解这篇文章主要介绍了PHP验证码类文件及调用方式代码详解,需要的朋友可以参考下
修改yii2.0用户登录使用的user表为其它的表实现方法(推荐)下面小编就为大家带来一篇修改yii2.0用户登录使用的user表为其它的表实现方法(推荐)。小编觉得挺不错的,现在就分
一个实用的php验证码类这篇文章主要为大家详细介绍了一个实用的php验证码类,具有一定的参考价值,感兴趣的小伙伴们可以参考一下