Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CompositeAuth auth methods to use their own user if defined #20308

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
continue;
}

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

Check warning on line 91 in framework/filters/auth/CompositeAuth.php

View check run for this annotation

Codecov / codecov/patch

framework/filters/auth/CompositeAuth.php#L91

Added line #L91 was not covered by tests
} elseif ($authUser != null) {
$user = $authUser;

Check warning on line 93 in framework/filters/auth/CompositeAuth.php

View check run for this annotation

Codecov / codecov/patch

framework/filters/auth/CompositeAuth.php#L93

Added line #L93 was not covered by tests
}

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