Tonight I tried Auth::attempt
in Laravel 5.2. I already read some case but, it's not solve my problem at all.
This is my doLogin function:
public function doLogin(LoginRequest $request)
{
$customer = [
'email' => $request->input('email'),
'password' => $request->input('password')
];
if (Customer::where('email', '=', $request->input('email'))->exists()) {
if (Auth::attempt($customer)) {
print_r(Auth::user());exit();
} else {
return response()->json([
'error' => true,
'status_code' => 400,
'message' => 'Wrong Credential, Please check your email or password'
]);
}
} else {
return response()->json([
'error' => true,
'status_code' => 404,
'message' => 'email not found'
]);
}
}
I'm already hashing the password stored in database using bcrypt()
and I have the password field in my database.
Also, I already changed the $primaryKey = 'customer_id';
But the result always returns false
(wrong credentials), did I wrote something wrong?