4

Is there a User Event before the authentication is fired?

I want to show a message if the user doesn't have a password yet and if it's his first login / check if he never logged in before - All in the frontend.

If so, send the activation / set password email.

So i tried the EVENT_BEFORE_VALIDATE


 Event::on(
            Users::class,
            Users::EVENT_BEFORE_VALIDATE,
            function (UserEvent $event) {

Which returns nothing.

And the EVENT_BEFORE_AUTHENTICATE event. This seems to what i am searching for. But it seems that the event only fires if the user already has a password. If the user never logged in / has no password it seems that this Event is never fired.

Event::on(
            User::class,
            User::EVENT_BEFORE_AUTHENTICATE,
            function (AuthenticateUserEvent $event) {
                dd($event);
            }
        );

0 Answers0