Skip to content

Commit

Permalink
Merge pull request #97 from baningo/fix/broken-i-am-logged-in-as
Browse files Browse the repository at this point in the history
Fix broken `amLoggedInAs` - method parameter is being overwritten
  • Loading branch information
SamMousa committed Feb 4, 2024
2 parents 219fbd9 + eb609b1 commit 2aa91e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Codeception/Lib/Connector/Yii2.php
Expand Up @@ -133,22 +133,22 @@ public function resetApplication(bool $closeSession = true): void
public function findAndLoginUser(int|string|IdentityInterface $user): void
{
$app = $this->getApplication();
$user = $app->get('user');
if (!$user instanceof User) {
$userComponent = $app->get('user');
if (!$userComponent instanceof User) {
throw new ConfigurationException('The user component is not configured');
}

if ($user instanceof \yii\web\IdentityInterface) {
$identity = $user;
} else {
// class name implementing IdentityInterface
$identityClass = $user->identityClass;
$identityClass = $userComponent->identityClass;
$identity = call_user_func([$identityClass, 'findIdentity'], $user);
if (!isset($identity)) {
throw new \RuntimeException('User not found');
}
}
$user->login($identity);
$userComponent->login($identity);
}

/**
Expand Down

0 comments on commit 2aa91e4

Please sign in to comment.