<p>Is there a User Event before the authentication is fired?</p>

<p>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.</p>

<p>If so, send the activation / set password email.</p>

<p>So i tried the <code>EVENT_BEFORE_VALIDATE</code> </p>

<pre><code>
 Event::on(
            Users::class,
            Users::EVENT_BEFORE_VALIDATE,
            function (UserEvent $event) {
</code></pre>

<p>Which returns nothing. </p>

<p>And the <code>EVENT_BEFORE_AUTHENTICATE</code> 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.</p>

<pre><code>Event::on(
            User::class,
            User::EVENT_BEFORE_AUTHENTICATE,
            function (AuthenticateUserEvent $event) {
                dd($event);
            }
        );
</code></pre>

CC BY-SA 4.0
2020-08-01T09:18:53.020Z
Also looking for this sort of behaviour. If you found a solution, workaround or differnt approach I''d love to hear it! 
Mere Development
CC BY-SA 4.0
2022-05-07T20:25:16.153Z
any solutions found?
Ra3d K
<craft3><users><events><authentication>
User Event before Login - check if user has password and logged in before
# User Event before Login - check if user has password and logged in before

(Asked by: username_0 on 2019-11-02)

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);
            }
        );

**Tags:** craft3, users, events, authentication

> **Comments:**
> **username_1**: Also looking for this sort of behaviour. If you found a solution, workaround or differnt approach I''d love to hear it!   
> **username_2**: any solutions found?  

---

## 0 answers

