yiisoft / yii2-app-basic

Yii 2.0 Basic Application Template

Home Page:http://www.yiiframework.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong attribute inside User.php

rfiedler opened this issue · comments

What steps will reproduce the problem?

1- site/login
2- Login ok
3- Error - Undefined property: app\models\User::$authKey

What's expected?

Login correctly

What do you get instead?

Error - Undefined property: app\models\User::$authKey

Additional info

Migration create user table with "auth_key" attribute but User Model call incorrect attribute inside function getAuthKey

public function getAuthKey()
{
return $this->authKey; <- Wrong attribute
return $this->auth_key; <- correct attribute
}

return $this->authKey;

Q A
Yii vesion 2.0.40
PHP version 7.4
Operating system Ubuntu 20.04

Fix this line too:

return $this->authKey === $authKey;

User model in basic app template is not an Active Record model and it's not related to a database. authKey property there is correct. If you are looking for db-based user model you can look at the User model of advanced app template.