Skip to content

Commit 029ca7e

Browse files
committed
minor symfony#53201 [Security] Reduce log level in case of UserNotFoundException in ContextListener (VincentLanglet)
This PR was merged into the 7.1 branch. Discussion ---------- [Security] Reduce log level in case of UserNotFoundException in ContextListener | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Issues | Fix symfony#50402 | License | MIT I didn't get a clear answer for symfony#50402 so I'm opening a PR about the suggested change to get opinion on it. There was a similar discussion, some message which could help: - `@fabpot` symfony#1073 (comment) - `@stof` symfony#1073 (comment) Here, the `UserNotFoundException` should be considered as a "normal" behavior to me. You can trigger it this way - Connect yourself with an account. - Ask someone else to deleted you account on an admin panel. - Refresh the page, since your account doesn't exist anymore, the Provider doesn't find your user, throw a NotFoundException - You're logged out I consider this as a normal behavior, so no warning shouldn't be logged and an info should be preferred. It's expected to not found a user after this one being deleted. That seems to be one of the purpose of the refreshUser method to returns null: - If the user changed - If the user doesn't exist WDYT ? Commits ------- deed930 Reduce log level
2 parents e974812 + deed930 commit 029ca7e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected function refreshUser(TokenInterface $token): ?TokenInterface
234234
} catch (UnsupportedUserException) {
235235
// let's try the next user provider
236236
} catch (UserNotFoundException $e) {
237-
$this->logger?->warning('Username could not be found in the selected user provider.', ['username' => $e->getUserIdentifier(), 'provider' => $provider::class]);
237+
$this->logger?->info('Username could not be found in the selected user provider.', ['username' => $e->getUserIdentifier(), 'provider' => $provider::class]);
238238

239239
$userNotFoundByProvider = true;
240240
}

0 commit comments

Comments
 (0)