'yii2 advanced login function always returns invalid username and password

I made no changes in yii login function but it returns error while giving correct username and password

public function actionLogin()
{
    if (!\Yii::$app->user->isGuest) {
        return $this->goHome();
    }

    $model = new LoginForm();
    if ($model->load(Yii::$app->request->post()) && $model->login()) {
        return $this->render('index');
    } else {
        return $this->render('login', [
            'model' => $model,
        ]);
    }
}


Solution 1:[1]

Try to use:

return $this->redirect(['site/index']);

instead return $this->render('index');

Solution 2:[2]

I've faced the same problem. For advanced template default signup scenario you need to activate your account by email confirmation (the email you provided at the time of signup). Until that moment your status is inactive. This status is used for login - only active users can log in.

If you're using this project for local purposes, you may change the status of your record in db table 'user' from 9(inactive) to 10(active). Then you will be able to login.

Solution 3:[3]

may me problem inside your user model, check validatePassword Or findByUser functions

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ankush Rishi
Solution 2 Yash
Solution 3 Ali Algmaty