Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #40672 [Security] [Passport] improve dx and document Authentica…
…tionException (jrushlow) This PR was merged into the 5.2 branch. Discussion ---------- [Security] [Passport] improve dx and document AuthenticationException | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | tbd `Passport::getUser()` (Instance of `UserPassportInterface::class`) throws an `AuthenticationException::class` if a user does not exist. Let's document that for better DX and visibility. Use case: - User login w/ a `username` that does not exist (custom json authenticator) - Attempt Authentication... - Auth failed `LoginFailureEvent` dispatched - snippet below: ```php // Userland\LoginFailureEventSubscriber::class public function dispatchFailure(LoginFailureEvent $event): void { $user = $event->getPassport()->getUser(); $message = new UserlandMessage($user); $this->messageBus->dispatch($message); } ``` - `401` status is returned. The above subscriber fails silently because a `UsernameNotFoundException` was ultimately thrown from `UserBadge::getUser()`. Commits ------- 97ceba0f5d improve dx and document auth exception
- Loading branch information