Answer the question
In order to leave comments, you need to log in
Why is authentication not saved in Laravel?
Authentication succeeds, but when I try to check whether he is authorized to use it or not, it returns false.
Authentication function:
public function login(Request $data) {
$credentials = [
'phone' => $data['phone'],
'password' => $data['password'],
];
if (Auth::attempt($credentials)) {
return response()->json(array('token' => Auth::user()->token), 200);
} else {
return response()->json(['error' => 'Incorrect phone or password',], 404);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question