Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to match input password and database hash password in laravel 4

How to authenticate a user password from a given request in Laravel? How is the password checked against the password hash stored in the database?

like image 941
user3825129 Avatar asked Aug 05 '14 06:08

user3825129


People also ask

How does laravel match hashed password?

From Laravel 5 onward, you can use the bcrypt() function to hash a plaintext. So, you can save that hashed password in DB and then, compare the hashed password again to match. $save_password = bcrypt('plain_text_password'); $check_password = bcrypt('provided_password_while_login_request'); And then, compare these two.

Can you decrypt hash password in laravel?

A hash is one-way and provides no method for decryption. You should send the user a link to reset their password. You shall never store user's literal password. Never, ever.


1 Answers

First, you'll need to find the User who is logging in based on email address or username or however you identify them, for example:

$user = User::where('email', '=', '[email protected]')->first(); 

Then, you'll need to CHECK the hashed password, like so:

Hash::check('INPUT PASSWORD', $user->password); 

This will return true or false based on whether or not the password matches.

like image 113
Darren Taylor Avatar answered Oct 09 '22 05:10

Darren Taylor