15 use Symfony\Component\HttpFoundation\JsonResponse;
16 use Symfony\Component\HttpFoundation\Request;
25 const NAME =
"manage-token";
31 function __construct()
33 parent::__construct(self::NAME,
45 protected function handle(Request $request)
51 list($tokenPk, $userId) = explode(
".", $tokenId);
55 $verifySql =
"SELECT user_fk FROM personal_access_tokens " .
56 "WHERE pat_pk = $1 LIMIT 1;";
58 $row = $this->
dbManager->getSingleRow($verifySql, [$tokenPk],
59 __METHOD__ .
".verifyToken");
60 if (empty($row) || $row[
'user_fk'] != $userId) {
66 $response =
new JsonResponse($this->revealToken($tokenPk,
67 $request->getHost()));
73 $response =
new JsonResponse([
"status" =>
false], 400);
85 function revealToken($tokenPk, $hostname=
"")
89 $restDbHelper = $container->get(
"helper.dbHelper");
91 $authHelper = $container->get(
'helper.authHelper');
93 $jti =
"$tokenPk.$user_pk";
95 $tokenInfo = $restDbHelper->getTokenKey($tokenPk);
96 if (!empty($tokenInfo[
'client_id'])) {
99 "token" => $tokenInfo[
'client_id']
102 $tokenScope = $tokenInfo[
'token_scope'];
104 $jwtToken = $authHelper->generateJwtToken($tokenInfo[
'expire_on'],
105 $tokenInfo[
'created_on'], $jti, $tokenScope, $tokenInfo[
'token_key']);
121 $restDbHelper = $container->get(
"helper.dbHelper");
122 $restDbHelper->invalidateToken($tokenPk);
129 register_plugin(
new AjaxManageToken());
Contains the constants and helpers for authentication of user.
static getUserId()
Get the current user's id.
Class to handle ajax calls to revoke an API token.
handle(Request $request)
Revoke an active API token.
invalidateToken($tokenPk)
Provides helper methods for REST api.
Provides helper methods to access database for REST api.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
fo_dbManager * dbManager
fo_dbManager object
list_t type structure used to keep various lists. (e.g. there are multiple lists).