Skip to content

Commit 81825d3

Browse files
mtangooStefano Mtangoo
and
Stefano Mtangoo
authored
Fix #20313: Allow CompositeAuth auth methods to use their own request and response if defined
Co-authored-by: Stefano Mtangoo <stefano@hosannahighertech.co.tz>
1 parent 61d459b commit 81825d3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Yii Framework 2 Change Log
2727
- Bug #20300: Clear stat cache in `FileCache::setValue()` (rob006)
2828
- Enh #20306: Add new `yii\helpers\ArrayHelper::flatten()` method (xcopy)
2929
- Bug #20308: Allow CompositeAuth auth methods to use their own user if defined (mtangoo)
30+
- Bug #20313: Allow CompositeAuth auth methods to use their own request and response if defined (mtangoo)
3031

3132
2.0.51 July 18, 2024
3233
--------------------

filters/auth/CompositeAuth.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ public function authenticate($user, $request, $response)
9393
$user = $authUser;
9494
}
9595

96+
$authRequest = $auth->request;
97+
if ($authRequest != null && !$authRequest instanceof \yii\web\Request) {
98+
throw new InvalidConfigException(get_class($authRequest) . ' must implement yii\web\Request');
99+
} elseif ($authRequest != null) {
100+
$request = $authRequest;
101+
}
102+
103+
$authResponse = $auth->response;
104+
if ($authResponse != null && !$authResponse instanceof \yii\web\Response) {
105+
throw new InvalidConfigException(get_class($authResponse) . ' must implement yii\web\Response');
106+
} elseif ($authResponse != null) {
107+
$response = $authResponse;
108+
}
109+
96110
$identity = $auth->authenticate($user, $request, $response);
97111
if ($identity !== null) {
98112
return $identity;

0 commit comments

Comments
 (0)