Skip to content

Dispatch a Authentication.authenticate event on successful authentication.#729

Closed
ADmad wants to merge 2 commits into3.nextfrom
3.4-events
Closed

Dispatch a Authentication.authenticate event on successful authentication.#729
ADmad wants to merge 2 commits into3.nextfrom
3.4-events

Conversation

@ADmad
Copy link
Copy Markdown
Member

@ADmad ADmad commented Jul 21, 2025

Subscribing to this event would allow the app to do to various like updating last login time, keep track of failed login attempts etc.

…ation.

Subscribing to this event would allow the app to do to various like updating
last login time, keep track of failed login attempts etc.
@ADmad ADmad changed the title Dispatch a Authentication.authenticate event on successfull authentication. Dispatch a Authentication.authenticate event on successful authentication. Jul 21, 2025
/** @var \Authentication\Authenticator\AuthenticatorInterface $authenticator */
foreach ($this->authenticators() as $authenticator) {
$result = $authenticator->authenticate($request);
$result = $this->dispatchAuthenticateEvent(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if this trigger on every request? Perhaps we should include that in the documentation?

Copy link
Copy Markdown
Member Author

@ADmad ADmad Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I overlooked the fact that this would trigger even when reading the user record from session. For the use cases I mentioned, the event is only needed for a login form POST. So triggering an event only from FormAuthenticate would make more sense.

@ADmad
Copy link
Copy Markdown
Member Author

ADmad commented Jul 25, 2025

I'll revisit this in the future, closing for now.

@ADmad ADmad closed this Jul 25, 2025
@ADmad ADmad deleted the 3.4-events branch July 25, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants