Skip to content

Commit

Permalink
Allow CompositeAuth auth methods to use their own user if defined
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Mtangoo committed Jan 13, 2025
1 parent fd866da commit e51d587
Showing 1 changed file with 8 additions and 0 deletions.
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 of a type 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

0 comments on commit e51d587

Please sign in to comment.