I try to make authorization on yii2. Created a form and when I send it, I get this error

Argument 1 passed to yii\web\User::login() must implement interface yii\web\IdentityInterface, null given, called in /frontend/models/auth/LoginForm.php on line 79 and defined 

This happens, as I understand it, when you call

 Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0); 

After reading on the Internet, I found a solution, but it did not help because my User class was created correctly

 class User extends ActiveRecord implements IdentityInterface 

What to do, what would not be this error?

  • 3
    > Argument 1 ... null given ... ... Your $this->getUser() method returns null , not the user's identity. Show it to us ... - Roman Grinyov
  • Did you override the WebUser class? Look at the implementation of the login method, in older versions it took one parameter instead of two. Try to update neatly framework - Ninazu
  • @Ninazu, yiiframework.com/doc-2.0/yii-web-user.html#login()-detail ... You will not leave so far in the framework if you update the framework with every simple exception. - Roman Grinyov

0