Laravel login as a username
I tried below function but it will throw the error invalid how to login with username instead of username
class TokenAuthController extends Controller
{
public function authenticate(Request $request)
{
$credentials = $request->only('username', 'password');
try {
if (! $token = JWTAuth::attempt($credentials)) {
return response()->json(['error' => 'invalid_credentials'], 401);
}
} catch (JWTException $e) {
return response()->json(['error' => 'could_not_create_token'], 500);
}
// if no errors are encountered we can return a JWT
return response()->json(compact('token'));
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2qLAeTp
via IFTTT
Aucun commentaire:
Enregistrer un commentaire