I'm trying to Login using Laravel and Vue.js its controller code is:
public function login(Request $request){
$validation = Validator::make($request->all(),[
'user_id' => 'required|email',
'password' => 'required|string|min:8|max:15',
]);
if ($validation->fails()) {
$response['status'] = false;
$response['message'] = $validation->errors()->first();
return response()->json($response,200);
}
if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
$user = Auth::user();
$token = $user->createToken('MyApp')->accessToken;
$user->api_token = $token;
$user->save();
return response()->json([
'status'=>true,
'message' => 'Login successfully',
'user' => $user,
], 200);
}
else{
return response()->json(['status'=>false,'message' => 'Invalid Login'], 200);
}
}
but i'm getting Invalid Login message
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire