RO
Size: a a a
RO
JF
❤
❤
❤
RO
JF
JF
RO
RO
RO
RO
JF
JF
JF
JF
$token = $_COOKIE['jwt'];
$secretKey = "___";
if (empty($token)) {
http_response_code(401);
return json_encode(array("message" => "The token is invalid"));
}
try {
$jwtData = JWT::decode($token, $secretKey, array("HS256"));
} catch (Exception $e) {
http_response_code(401);
return json_encode(array("message" => "The token is invalid"));
}
JF
$userDao = new UserDao();
try {
$user = $userDao->get($jwtData -> data -> id);
if ($user -> getLogin() !== $jwtData -> data -> login
|| $user -> getPassword() !== $jwtData -> data -> password
|| $user -> getName() !== $jwtData -> data -> name) {
http_response_code(401);
return json_encode(array("message" => "The user is invalid"));
return false;
}
} catch (NotFoundItemException $e) {
http_response_code(401);
return json_encode(array("message" => "The user does not exist"));
return false;
}
CV
$token = $_COOKIE['jwt'];
$secretKey = "___";
if (empty($token)) {
http_response_code(401);
return json_encode(array("message" => "The token is invalid"));
}
try {
$jwtData = JWT::decode($token, $secretKey, array("HS256"));
} catch (Exception $e) {
http_response_code(401);
return json_encode(array("message" => "The token is invalid"));
}
JF