Password always incorrect after signing up

In my advanced application, after signing up it supposed to be already logged in but after signing up and trying to login it always says that I input the right credentials even though I tried testing it using "qwerty" as a password.

I haven’t done anything yet on the signup form model only the customization that is needed to match the user table.

When I check the database it records the data but everytime I login it always says that I input the wrong credentials.

public function rules()


        return [

            ['username', 'trim'],

            ['username', 'required'],

            ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'],

            ['username', 'string', 'min' => 2, 'max' => 255],

            ['email', 'trim'],

            ['email', 'required'],

            ['email', 'email'],

            ['email', 'string', 'max' => 255],

            ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],

            ['password', 'required'],

            ['password', 'string', 'min' => 6],

            ['first_name', 'required'],

            ['first_name', 'string', 'max' => 45],

            ['middle_name', 'string', 'max' => 45],

            ['last_name', 'required'],

            ['last_name', 'string', 'max' => 45],

            ['contact', 'required'],

            ['contact', 'string', 'max' => 11],

            ['birth_date', 'required'],

            ['type', 'required'],

            ['type', 'string', 'max' => 45],

            ['external_type', 'string', 'max' => 45],

            ['status', 'string', 'max' => 45],

            ['region_id', 'required'],

            ['barangay_id', 'required'],

            ['province_id', 'required'],

            ['city_municipal_id', 'required'],

this is the signup()

 public function signup()


        if (!$this->validate()) {

            return null;



        $user = new User();

        $user->username = $this->username;

        $user->email = $this->email;



        $user->first_name = $this->first_name;

        $user->middle_name = $this->middle_name;

        $user->last_name = $this->last_name;

        $user->contact = $this->contact;

        $user->birth_date = $this->birth_date;

        $user->type = $this->type;

        $user->external_type = $this->external_type;

        $user->status = $this->status;

        $user->region_id = $this->region_id;

        $user->barangay_id = $this->barangay_id;

        $user->province_id = $this->province_id;

        $user->city_municipal_id = $this->city_municipal_id;

        return $user->save() ? $user : null;




I don’t see anything wrong in your posted code.

Do you say that you tried to login when you were already logged in? But usually you can’t access login action when you are logged in.

This seems to contradict what you say in the first quote.

Sorry what I mean is that after the registration

After registration, it redirects me to the index page but it still not logged in it supposed to be already logged in after signing up right? But when I try to login again it always says wrong password even though I entered the right password.


After browsing the forum I’ve found a similar problem

What about the configuration of ‘user’ component?

        'user' => [

            'identityClass' => 'app\models\User',

            'enableAutoLogin' => true,


If you have a different class name for the user table, you have to modify this part accordingly.

I don’t have a different classname, I tried installing Yii2 again, I used the user table (My link) after the migration. I tried registering another user, and nothing happens. It just load again the page.

The table in your link doesn’t have ‘first_name’, ‘middle_name’, ‘last_name’, … etc. What is the table name (and the corresponding model name) that has those fields?

Yes the table in my link is just an example because I’ve tried to create a new one but it still doesn’t work even I only used the user table that came from the yii migration.

Here is the user table that I’ve been using.

I’m still stuck here hahaha, maybe I will just try to install a lower version of Yii2 Advanced App

Hold on, my friend. You’re gonna make it all right! :)

Yeah, I agree with you. I would start from the scratch again, installing yii2-app-advanced anew, and confirm that signing-up and logging-in work as expected before proceeding to the customization of the user model.

So I started again from scratch and I used the the user table from migration, after signing up it works fine also the login. I proceed with the customization of the SignupForm model and it doesn’t work anymore but it records the data the I filled up in the user table.

The User Table

The data was been saved in the user table


Did you change the configuration of the ‘user’ component? If you are using “SignupForm” model in place of the “User” model, you have to re-configure it.

        'user' => [

            // 'identityClass' => 'common\models\User',

            'identityClass' => 'common\models\SignupForm',  // or something like that

            'enableAutoLogin' => true,

            'identityCookie' => ['name' => '_identity-frontend', 'httpOnly' => true],


Try this solution…
In common/models/User.php

    public function rules()
    return [
        ['status', 'default', 'value' => self::STATUS_INACTIVE],
        ['status', 'in', 'range' => [self::STATUS_ACTIVE, 
        self::STATUS_INACTIVE, self::STATUS_DELETED]],

In this method, set the default ‘value’=>self::STATUS_ACTIVE your problem will be solved. I also had the same issue. After changing the value to Active, it worked, because the default value it is setting is 9 and the database considers it an inactive entry that’s why it is showing incorrect id or password. I hope this helps.