user13153726
user13153726

Reputation:

How can check whether my hash password store in the right way in database?

I created a simple multiauth in Laravel (admin, user). They both authorize the user and admin login normally.

Yesterday, when I open the admin login page and try to login, it shows me

These credentials do not match our records.

I said OK maybe I wrote the incorrect password. I made a new account via Seed like this:

AdminSeeder.php

public function run()
{
    Admin::create([
        'name'=>'admin',
        'email'=>'[email protected]',
        'password'=> Hash::make('123456'),
    ]);
}

I go again and try to login with the correct credentials, but I got the same error message. Then I tried to make a new user via Tinker, to verify if there is an error in my Seed. I create new one and then try to login but I get the same error.

In my admin panel I created a page for admin to add more than one admin! Again I create a new admin account from my page and login, here it works! with the same HASH function in seed!

Next, I tried to create a new Laravel project and just move my important files to new one, again the same thing with the new one!

I really don't know what's going on! I think there is a problem in hash password when I create a new account via Seed and Tinker!

Upvotes: 0

Views: 204

Answers (1)

D. Petrov
D. Petrov

Reputation: 1167

It turned out, password was getting hashed twice due to an extensive custom password setter in the Admin model. Issue was resolved by removing the mentioned setter.

Upvotes: 1

Related Questions