How will I set if account_status = 1 then I can able to login otherwise not able to login? email, phone and password must be there. This is the following code
public function login(Request $request){
if(Auth::attempt(['email' => request('email'), 'password' => request('password'),
'account_status'=> request('account_status')])){
$user = Auth::user();
$success['token'] = $user->createToken('MyApp')-> accessToken;
return response()->json(['success' => $success], $this-> successStatus);
}
else if(Auth::attempt(['phone' => request('phone'), 'password' => request('password'),
'account_status'=> request('account_status')])){
$user = Auth::user();
$success['token'] = $user->createToken('MyApp')-> accessToken;
return response()->json(['success' => $success], $this-> successStatus);
}
else{
return response()->json(['error'=>'Unauthorised'], 401);
}
}
Please help me out to solve this problem i'll be grateful to you
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire