Check user password before send mail

Hi
I would like to send an email only if the user provide his password (the same he use for login in the system).
The password is hashed with argon2.
I would like to provide a modal with an input text to insert the password.
Can someone explain me how to do that?
Thanks

Hey there,

Here is how I could try to achieve this:

  1. Create the modal and include a form with a password field inside.
  2. Create a server action with a validation step as following.

Make sure to compare the encrypted password values. It’s not possible to decrypt the password, but you can compare the encrypted values, so if it’s equal, then the server action can go to the next step which is sending an email eventually. :slight_smile:

Hope that helps!

Edit: Forget that, it seems that the compare option doesn’t work with dynamic things… :thinking:

The solution would be to retrieve the hashed password in the server action, then use a condition:

  • if the retrieved password == the hashed password sent via the form input → send the email

I haven’t tested it, but I think this should work @pernetpervenches :slight_smile:

1 Like

Thanks ChristopheA. I’ll try this way and let you know.