Skip to content

Commit 9e0f451

Browse files
mtangooStefano Mtangoo
authored andcommitted
Fix yiisoft#20308: Allow CompositeAuth auth methods to use their own user if defined
Co-authored-by: Stefano Mtangoo <[email protected]>
1 parent 283d336 commit 9e0f451

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Yii Framework 2 Change Log
3838
- Bug #20296: Fix broken enum test (briedis)
3939
- Bug #20300: Clear stat cache in `FileCache::setValue()` (rob006)
4040
- Enh #20306: Add new `yii\helpers\ArrayHelper::flatten()` method (xcopy)
41+
- Bug #20308: Allow CompositeAuth auth methods to use their own user if defined (mtangoo)
4142

4243
2.0.51 July 18, 2024
4344
--------------------

framework/filters/auth/CompositeAuth.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ public function authenticate($user, $request, $response)
8686
continue;
8787
}
8888

89+
$authUser = $auth->user;
90+
if ($authUser != null && !$authUser instanceof \yii\web\User) {
91+
throw new InvalidConfigException(get_class($authUser) . ' must implement yii\web\User');
92+
} elseif ($authUser != null) {
93+
$user = $authUser;
94+
}
95+
8996
$identity = $auth->authenticate($user, $request, $response);
9097
if ($identity !== null) {
9198
return $identity;

0 commit comments

Comments
 (0)