chimera-mark2-core-release/core/fox/auth/renew.php

29 lines
738 B
PHP
Raw Permalink Normal View History

2023-03-07 11:25:14 +00:00
<?php
namespace fox\auth;
use fox\externalCallable;
use fox\foxException;
use fox\request;
use fox\authJwt;
class renew implements externalCallable {
public static function APICall(request $request) {
if (!$request->authOK) {
throw new foxException("Unauthorized", 401);
}
if ($request->token->renewed) {
trigger_error("Token already renewed by automatic");
} else {
$request->token->renew();
}
return [
"token" => $request->token->token,
"expire" => $request->token->expireStamp->isNull() ? "Never" : $request->token->expireStamp,
"jwt"=>authJwt::issueByAuthToken($request->token)
];
}
}