Browse Source

readd username to token #1577

CauseFX 4 years ago
parent
commit
6ff55f16c2
2 changed files with 2 additions and 2 deletions
  1. 1 1
      api/classes/organizr.class.php
  2. 1 1
      api/functions/token-functions.php

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

@@ -3333,7 +3333,7 @@ class Organizr
 		->identifiedBy('4f1g23a12aa', true)// Configures the id (jti claim), replicating as a header item
 		->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('username', $result['username'])// Configures a new claim, called "username"
 		->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"

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

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