Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dra_01's avatar

Can't login after registration, says "invalid password"

I've been building an application usign laravel, it was all going alright and auth system was working correctly, but after i did a migrate:fresh command using artisan i can create an account but i can't login using it.

I have not changed anything on laravel's default auth system and the only change i made since it was working was add a model/controller/migration named "Posts" and i tried removing it and anything related to it but yet nothing changed.

I believe it has something to do with the users generated hash because if i put the hash from UserFactory in the database which is "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi" i can login using "password" as password and everything works fine.

I'm not getting an error or anything else except that credentials don't work.

0 likes
9 replies
Snapey's avatar

how did you create your user and password?

dra_01's avatar

through the registration system laravel provides

create function on RegisterController contains this:

return User::create([ 'name' => $data['name'], 'username' => $data['username'], 'email' => $data['email'], 'password' => Hash::make($data['password']), // ]);

the function gets called during registration but even if i change the 'password' field to smthg for ex. 'password' => 'Password123' it still saves a hash and not 'Password123' so i believe there is smthg changing the password field after registration

dra_01's avatar

Hmm changing Hash::make($data['password']), to simply $data['password'] fixed it, idk why this happened even tho i didn't do any updates or anything and it worked only a few hours ago also to mention that Hash::make($data['password']) was there by default

Sinnbeck's avatar

Try running the following and try again

php artisan config:clear 
php artisan key:generate 
php artisan migrate:fresh
Sinnbeck's avatar

So you are saving the password directly in the db unhashed?

dra_01's avatar

No the password is being hashed somewhere else before saved in database https://i.imgur.com/cgJi7ze.png I'm also wondering myself why is this so when just some hours ago everything was fine with Hash::make in "create" function

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Did you perhaps add a mutator to the user model?

dra_01's avatar

Oh i totally forgot i did that, yes I have added a mutator for the password in the user model.

Please or to participate in this conversation.