Skip to content

Commit

Permalink
Fix #20308: Allow CompositeAuth auth methods to use their own user if…
Browse files Browse the repository at this point in the history
… defined

Co-authored-by: Stefano Mtangoo <stefano@hosannahighertech.co.tz>
  • Loading branch information
mtangoo and Stefano Mtangoo authored Jan 14, 2025
1 parent fd866da commit b0b7832
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Yii Framework 2 Change Log
- Bug #20296: Fix broken enum test (briedis)
- Bug #20300: Clear stat cache in `FileCache::setValue()` (rob006)
- Enh #20306: Add new `yii\helpers\ArrayHelper::flatten()` method (xcopy)
- Bug #20308: Allow CompositeAuth auth methods to use their own user if defined (mtangoo)

2.0.51 July 18, 2024
--------------------
Expand Down
8 changes: 8 additions & 0 deletions framework/filters/auth/CompositeAuth.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
Expand Down Expand Up @@ -85,6 +86,13 @@ public function authenticate($user, $request, $response)
continue;
}

$authUser = $auth->user;
if ($authUser != null && !$authUser instanceof \yii\web\User) {
throw new InvalidConfigException(get_class($authUser) . ' must implement yii\web\User');
} elseif ($authUser != null) {
$user = $authUser;
}

$identity = $auth->authenticate($user, $request, $response);
if ($identity !== null) {
return $identity;
Expand Down

0 comments on commit b0b7832

Please sign in to comment.