gothinkster / laravel-realworld-example-app

Exemplary real world backend API built with Laravel
https://realworld.io
MIT License
1.2k stars 1.05k forks source link

[Fix] Password not hashing before saving to DB #26

Closed pravnyadv closed 4 years ago

pravnyadv commented 4 years ago

i was having issues while login from API so i looked in db and it was saving password as plain text so i tried this fix and it worked.

sandeesh commented 4 years ago

The User model has a mutator that encrypts the password if a plaintext password is stored and skips it if the stored password is already an encrypted hash. https://github.com/gothinkster/laravel-realworld-example-app/blob/master/app/User.php#L41

I'll merge this PR just so this becomes clear for the users and people don't make the mistake of storing plain text password by copying this approach.