bobysky

bobysky

这家伙有点懒,还没写个性签名!

  • 财富值0
  • 威望值0
  • 总积分230

个人信息

  • 登录的代码

    app\models\loginform

    public function login()
        {
            if ($this->validate()) {
                return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30 : 0);
            } else {
                return false;
            }
        }
    
       public function getUser()
        {
            if ($this->_user === false) {
                $this->_user = User::findByUsername($this->username);
            }
    
            return $this->_user;
        }
    

    app\models\user

    class User extends ActiveRecord implements \yii\web\IdentityInterface
    {
        public $rememberMe;
        public $username;
        public $password;
    
    
        public static function tableName()
        {
            return '{{%user}}';
        }
    
    
        public static function findIdentity($id){
            return static::findOne($id);
        }
    
        /**
         * @inheritdoc
         */
        public static function findIdentityByAccessToken($token, $type = null)
        {
            return static::findOne(['access_token' => $token]);
        }
    
        /**
         * Finds user by username
         *
         * @param  string      $username
         * @return static|null
         */
        public static function findByUsername($username)
        {
            $user = User::find()
                ->where(['UserName' => $username])
                ->asArray()
                ->one();
            if($user){
                return new static($user);
            }
    
            return null;
        }
    
        /**
         * @inheritdoc
         */
        public function getId()
        {
            return $this->UserName;
        }
    
        /**
         * @inheritdoc
         */
        public function getAuthKey()
        {
            return $this->authKey;
        }
    
        /**
         * @inheritdoc
         */
        public function validateAuthKey($authKey)
        {
            return $this->authKey === $authKey;
        }
    
        /**
         * Validates password
         *
         * @param  string  $password password to validate
         * @return boolean if password provided is valid for current user
         */
    
        public function validatePassword($password)
        {
            if($password===$password){
                return true;
            }else{
                return false;
            }
        }
    
        public function test(){
            $user=user::findOne(['username'=>'3color']);
            var_dump($user);
        }
    }
    
  • 回复了 的回答

    那就是没登陆成功!!

    @gn_zhu: 登录成功了的,有写入session了。

  • 提出了问题
    登录后Yii::$app->user->isGuest的值未被改变
  • 发布了话题
    怎么让每个视图文件引入不同css文件
  • 飞哥,我执行php -S localhost:8000后, CLI停止工作,是什么原因?我的php版本5.4.3

见习主管 等级规则
230/500
资料完整度
20/100
用户活跃度
0/100

Ta的关注

0

Ta的粉丝

6

Ta的访客

16