From ea47b75c92f0ee4090b6bad134f37e727209b1cd Mon Sep 17 00:00:00 2001 From: Guillaume Heurtier <guillaume.heurtier@maarch.org> Date: Fri, 17 Feb 2023 16:58:24 +0100 Subject: [PATCH] FEAT #22797 TIME 0:20 fix decoded token user as array --- src/app/user/controllers/UserController.php | 1 + src/core/controllers/AuthenticationController.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index a98ac0f66d..cffdeb0ace 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -768,6 +768,7 @@ class UserController try { $jwt = AuthenticationModel::decodeToken($body['token'], CoreConfigModel::getEncryptKey()); + $jwt['user'] = (array)$jwt['user'] ?? []; } catch (\Exception $e) { return $response->withStatus(403)->withJson(['errors' => 'Invalid token', 'lang' => 'invalidToken']); } diff --git a/src/core/controllers/AuthenticationController.php b/src/core/controllers/AuthenticationController.php index e92e6adba5..1df635b98b 100755 --- a/src/core/controllers/AuthenticationController.php +++ b/src/core/controllers/AuthenticationController.php @@ -364,6 +364,7 @@ class AuthenticationController try { $jwt = AuthenticationModel::decodeToken($queryParams['refreshToken'], CoreConfigModel::getEncryptKey()); + $jwt['user'] = (array)$jwt['user'] ?? []; } catch (\Exception $e) { return $response->withStatus(401)->withJson(['errors' => 'Authentication Failed']); } -- GitLab