35 const NAME =
"manage-token";
41 function __construct()
43 parent::__construct(self::NAME,
55 protected function handle(Request $request)
61 list($tokenPk, $userId) = explode(
".", $tokenId);
65 $verifySql =
"SELECT user_fk FROM personal_access_tokens " .
66 "WHERE pat_pk = $1 LIMIT 1;";
68 $row = $this->
dbManager->getSingleRow($verifySql, [$tokenPk],
69 __METHOD__ .
".verifyToken");
70 if (empty($row) || $row[
'user_fk'] != $userId) {
76 $response =
new JsonResponse($this->
revealToken($tokenPk,
77 $request->getHost()));
83 $response =
new JsonResponse([
"status" =>
false], 400);
98 $restDbHelper = $container->get(
"helper.dbHelper");
99 $authHelper = $container->get(
'helper.authHelper');
101 $jti =
"$tokenPk.$user_pk";
103 $tokenInfo = $restDbHelper->getTokenKey($tokenPk);
106 $jwtToken = $authHelper->generateJwtToken($tokenInfo[
'expire_on'],
107 $tokenInfo[
'created_on'], $jti, $tokenScope, $tokenInfo[
'token_key']);
123 $restDbHelper = $container->get(
"helper.dbHelper");
124 $restDbHelper->invalidateToken($tokenPk);
revealToken($tokenPk, $hostname)
static getUserId()
Get the current user's id.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
invalidateToken($tokenPk)
Class to handle ajax calls to revoke an API token.
fo_dbManager * dbManager
fo_dbManager object
list_t type structure used to keep various lists. (e.g. there are multiple lists).
handle(Request $request)
Revoke an active API token.