Skip to content

Commit 0a91ec6

Browse files
committed
Release 1.1.2
1 parent d19dad8 commit 0a91ec6

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

authclient/JWT.php

+16-5
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function authAction($authAction)
7676
if (!Yii::$app->user->isGuest) {
7777
Yii::$app->user->logout();
7878
}
79-
79+
8080
if ($token == '') {
8181
return $this->redirectToBroker();
8282
}
@@ -89,7 +89,7 @@ public function authAction($authAction)
8989
return Yii::$app->getResponse()->redirect(['/user/auth/login']);
9090
}
9191

92-
$this->setUserAttributes((array) $decodedJWT);
92+
$this->setUserAttributes((array)$decodedJWT);
9393
$this->autoStoreAuthClient();
9494

9595

@@ -157,13 +157,24 @@ protected function defaultTitle()
157157
*/
158158
protected function autoStoreAuthClient()
159159
{
160-
$attributes = $this->getUserAttributes();
161-
$user = User::findOne(['email' => $attributes['email']]);
162-
if ($user !== null) {
160+
if ($this->getUserByAttributes() !== null) {
163161
(new AuthClientUserService($user))->add($this);
164162
}
165163
}
166164

165+
/**
166+
* @return User|null
167+
*/
168+
protected function getUserByAttributes()
169+
{
170+
$attributes = $this->getUserAttributes();
171+
if (isset($attributes['email'])) {
172+
return User::findOne(['email' => $attributes['email']]);
173+
}
174+
175+
return null;
176+
}
177+
167178
public function checkIPAccess()
168179
{
169180
if (empty($this->allowedIPs)) {

authclient/JWTPrimary.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class JWTPrimary extends JWT implements PrimaryClient, AutoSyncUsers, SyncAttrib
1212

1313
public function getUser()
1414
{
15-
// Not supported
16-
return null;
15+
return $this->getUserByAttributes();
1716
}
1817

1918
/**

docs/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Changelog
22
=========
33

4+
1.1.2 (November 23, 2023)
5+
-------------------------
6+
7+
- Enh: Fixed Login Issue with `JWTPrimary` AuthClient
8+
49
1.1.1 (June 14, 2023)
510
--------------------
611

module.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"sso",
88
"login"
99
],
10-
"version": "1.1.1",
10+
"version": "1.1.2",
1111
"humhub": {
1212
"minVersion": "1.14"
1313
},

0 commit comments

Comments
 (0)