Browse Source

Merge pull request #1466 from TehMuffinMoo/v2-develop

Add /token/validate v2 API endpoint
causefx 5 years ago
parent
commit
6d2773be5e
1 changed files with 12 additions and 1 deletions
  1. 12 1
      api/v2/routes/token.php

+ 12 - 1
api/v2/routes/token.php

@@ -8,4 +8,15 @@ $app->delete('/token/{id}', function ($request, $response, $args) {
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')
 		->withStatus($GLOBALS['responseCode']);
-});
+});
+
+$app->post('/token/validate', function ($request, $response, $args) {
+        $Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
+        if ($Organizr->qualifyRequest(999, true)) {
+                $GLOBALS['api']['response']['data'] = $Organizr->jwtParse($_REQUEST["Token"]);
+        }
+        $response->getBody()->write(jsonE($GLOBALS['api']));
+        return $response
+                ->withHeader('Content-Type', 'application/json;charset=UTF-8')
+                ->withStatus($GLOBALS['responseCode']);
+});