Selaa lähdekoodia

Merge pull request #1711 from Yann-J/v2-master

Rename JWT username claim to name
causefx 4 vuotta sitten
vanhempi
commit
e2f35ea5d8
2 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 3 3
      api/classes/organizr.class.php
  2. 1 1
      api/functions/token-functions.php

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

@@ -366,7 +366,7 @@ class Organizr
 			],
 			411 => [
 				'type' => 'Length Required',
-				'description' => 'The request can not be processed without a “Content-Length” header field'
+				'description' => 'The request can not be processed without a "Content-Length" header field'
 			],
 			412 => [
 				'type' => 'Precondition Failed',
@@ -3635,7 +3635,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('name', $result['username'])// Configures a new claim, called "name"
 		->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"
@@ -5777,7 +5777,7 @@ class Organizr
 				foreach ($contents as $content) {
 					$html = $content->innerHtml;
 					preg_match('/(@[a-zA-Z])\w+/', $html, $username);
-					preg_match('/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'\".,<>?«»“”‘’]))/', $html, $image);
+					preg_match('/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'\".,<>?«»""'']))/', $html, $image);
 					if (isset($image[0]) && isset($username[0])) {
 						$sponsors[] = [
 							'name' => str_replace('@', '', $username[0]),

+ 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->hasClaim('username')) ? $jwttoken->getClaim('username') : 'N/A';
+					$result['username'] = ($jwttoken->hasClaim('name')) ? $jwttoken->getClaim('name') : 'N/A';
 					$result['group'] = ($jwttoken->hasClaim('group')) ? $jwttoken->getClaim('group') : 'N/A';
 					$result['groupID'] = $jwttoken->getClaim('groupID');
 					$result['userID'] = $jwttoken->getClaim('userID');