Skip to content

Commit 5783ba3

Browse files
mtangooStefano Mtangoo
and
Stefano Mtangoo
authored
Fix #20308: Allow CompositeAuth auth methods to use their own user if defined
Co-authored-by: Stefano Mtangoo <stefano@hosannahighertech.co.tz>
1 parent e8ac65a commit 5783ba3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

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

3031
2.0.51 July 18, 2024
3132
--------------------

filters/auth/CompositeAuth.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @link https://www.yiiframework.com/
45
* @copyright Copyright (c) 2008 Yii Software LLC
@@ -85,6 +86,13 @@ public function authenticate($user, $request, $response)
8586
continue;
8687
}
8788

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+
8896
$identity = $auth->authenticate($user, $request, $response);
8997
if ($identity !== null) {
9098
return $identity;

0 commit comments

Comments
 (0)