diff --git a/authclient/JWT.php b/authclient/JWT.php index fbf50d5..8ec3e08 100644 --- a/authclient/JWT.php +++ b/authclient/JWT.php @@ -76,7 +76,7 @@ public function authAction($authAction) if (!Yii::$app->user->isGuest) { Yii::$app->user->logout(); } - + if ($token == '') { return $this->redirectToBroker(); } @@ -89,7 +89,7 @@ public function authAction($authAction) return Yii::$app->getResponse()->redirect(['/user/auth/login']); } - $this->setUserAttributes((array) $decodedJWT); + $this->setUserAttributes((array)$decodedJWT); $this->autoStoreAuthClient(); @@ -157,13 +157,24 @@ protected function defaultTitle() */ protected function autoStoreAuthClient() { - $attributes = $this->getUserAttributes(); - $user = User::findOne(['email' => $attributes['email']]); - if ($user !== null) { + if ($this->getUserByAttributes() !== null) { (new AuthClientUserService($user))->add($this); } } + /** + * @return User|null + */ + protected function getUserByAttributes() + { + $attributes = $this->getUserAttributes(); + if (isset($attributes['email'])) { + return User::findOne(['email' => $attributes['email']]); + } + + return null; + } + public function checkIPAccess() { if (empty($this->allowedIPs)) { diff --git a/authclient/JWTPrimary.php b/authclient/JWTPrimary.php index 1cf5f7d..d306999 100644 --- a/authclient/JWTPrimary.php +++ b/authclient/JWTPrimary.php @@ -12,8 +12,7 @@ class JWTPrimary extends JWT implements PrimaryClient, AutoSyncUsers, SyncAttrib public function getUser() { - // Not supported - return null; + return $this->getUserByAttributes(); } /** diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f704101..971353b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,11 @@ Changelog ========= +1.1.2 (November 23, 2023) +------------------------- + +- Enh: Fixed Login Issue with `JWTPrimary` AuthClient + 1.1.1 (June 14, 2023) -------------------- diff --git a/module.json b/module.json index b23fcb7..ec803bd 100644 --- a/module.json +++ b/module.json @@ -7,7 +7,7 @@ "sso", "login" ], - "version": "1.1.1", + "version": "1.1.2", "humhub": { "minVersion": "1.14" },