I am building laravel API of my website . I am using laravel 5.3
I am using the API in building mobile app .
In login section, there are two fields :
- Enter email or username
- Enter password
In my DB , email and username are different columns.
Here is the function:
public function authenticate()
{
$credentials=request()->only('username','password');
try {
$token=JWTAuth::attempt($credentials);
if(!$token){
return response()->json(['error'=>'credentials wrong'],401);
}
}
catch(JWTException $e) {
return response()->json(['error'=>'something_went_wrong'],500);
}
return response()->json(['token'=>$token],200);
}
Here only username is used,I want to use both username and password.
If need any other info please ask.
ty:)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire