When trying to compare the password in pure text with the password encrypted in the database, the Hash::check()
method always returns false
, and should return true
Authentication code:
$email = $request->input('email');
$password = $request->input('password');
$user = User::where('email', $email)->first();
if ($user) {
if (Hash::check($password, $user->password)) {
$token = $this->JWTAuth->fromUser($user);
return response()->json(['token' => $token, 'user' => $user], 200);
}
}
return 'FAIL';
/*abaixo o modo que eu crio o hash para o campo password*/
$user->fill([
'password' => Hash::make($password)
])->save();
Note: Framework Laravel 5.4