Helper Helper - 5 months ago 11x
PHP Question

How to use hasher::check in custom class to validate credentials for Token based authentication API

I am working on Token based authentication in which user will send Post request from Android to Laravel. Header will have Username and Encrypted Password. I am able to decrypt the password sent from Android to Laravel. Now I have plan Password.

Now the issue is: I need to compare it with AuthPassword. Can somebody advice how can I use hasher::check in my class so that I can check if credentials are correct or not?

I know, we have api_token in User Model, but in my requirement, user can do the Registration/Login from Android also.


It's simple:

 //fetch current user, left for you how you do this:
$user = User::find('id');

//pick hashed password from db
$hashed = $user->password;

$password = 'the plain password';

//compare hashed and plain password 
If(\Hash::check($password, $hashed)){