Ver Fonte

Re-add JWT claims removed from token (#1577)

CauseFX há 5 anos atrás
pai
commit
1d45083ea7
2 ficheiros alterados com 2 adições e 2 exclusões
  1. 1 1
      api/classes/organizr.class.php
  2. 1 1
      api/functions/token-functions.php

+ 1 - 1
api/classes/organizr.class.php

@@ -2877,7 +2877,7 @@ class Organizr
 		->issuedAt(time())// Configures the time that the token was issue (iat claim)
 		->expiresAt(time() + (86400 * $days))// Configures the expiration time of the token (exp claim)
 		//->withClaim('username', $result['username'])// Configures a new claim, called "username"
-		//->withClaim('group', $result['group'])// Configures a new claim, called "group"
+		->withClaim('group', $result['group'])// Configures a new claim, called "group"
 		//->withClaim('groupID', $result['group_id'])// Configures a new claim, called "groupID"
 		//->withClaim('email', $result['email'])// Configures a new claim, called "email"
 		//->withClaim('image', $result['image'])// Configures a new claim, called "image"

+ 1 - 1
api/functions/token-functions.php

@@ -26,7 +26,7 @@ trait TokenFunctions
 				if ($jwttoken->validate($data)) {
 					$result['valid'] = true;
 					//$result['username'] = $jwttoken->getClaim('username');
-					//$result['group'] = $jwttoken->getClaim('group');
+					$result['group'] = ($jwttoken->hasClaim('group')) ? $jwttoken->getClaim('group') : 'N/A';
 					//$result['groupID'] = $jwttoken->getClaim('groupID');
 					$result['userID'] = $jwttoken->getClaim('userID');
 					//$result['email'] = $jwttoken->getClaim('email');