zoukankan      html  css  js  c++  java
  • Yii UserIdentity中的authenticate

    authenticate方法,根据验证结果,返回各种错误码,包括

        const ERROR_NONE=0;
        const ERROR_USERNAME_INVALID=1;
        const ERROR_PASSWORD_INVALID=2;
        const ERROR_UNKNOWN_IDENTITY=100;

    这样,在判断验证结果的时候,直接读取自缩写的定义身份类的errorCode属性就可以判断了

    class UserIdentity extends CUserIdentity
    {
    private $_id;
    public function authenticate()
    {
    $record=User::model()->findByAttributes(array('username'=>$this->username));
    if($record===null)
    $this->errorCode=self::ERROR_USERNAME_INVALID;
    else if($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;
    }
    第 79 页 共 112return !$this->errorCode;
    }
  • 相关阅读:
    密码学基础(三)
    密码学基础(二)
    密码学基础(一)
    Lambda代数
    恢复系统
    11.22面试例题
    js中级复习
    11.12
    11.13
    定时器
  • 原文地址:https://www.cnblogs.com/ch459742906/p/5746912.html
Copyright © 2011-2022 走看看