Вот код:
Код: Выделить всё
public function loginJwt(Request $request)
{
$secure_random_token = $request->input('validate');
$token = Cache::pull($secure_random_token);
if (!$token) {
throw new AuthenticationException('Validasi request gagal[2]: Token is gone');
}
try {
$payload = JWTAuth::setToken($token)->getPayload();
} catch (TokenExpiredException $e) {
abort(400, $e->getMessage());
} catch (Exception $e) {
abort(400, $e->getMessage());
}
// If the class is using the ThrottlesLogins trait, we can automatically throttle
// the login attempts for this application. We'll key this by the username and
// the IP address of the client making these requests into this application.
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
}
if ($this->attemptJwtLogin($request, $token, $payload)) {
$this->_jwt_tmp = $token;
return $this->sendLoginResponse($request);
}
return view('auth.failed');
}
Код: Выделить всё
[2023-05-08 14:01:12] local.WARNING: {"username":null,"jwtId":null,"path":"\/","input":[],"method":"GET","originator":["127.0.0.1"],"header":["authorization","cookie","accept"],"exception":{"class":"Illuminate\\Auth\\AuthenticationException","message":"Unauthenticated."}}
Подробнее здесь: https://stackoverflow.com/questions/761 ... -using-jwt