aaronrenner / phx_gen_auth

An authentication system generator for Phoenix 1.5 applications.
772 stars 55 forks source link

User is logged in right away after registration #123

Closed marschro closed 3 years ago

marschro commented 3 years ago

Hi @aaronrenner,

I was wondering about the strategy to log in a user right away after the registration. In my case, the login should only be possible if the user confirmed the mail address.

https://github.com/aaronrenner/phx_gen_auth/blob/a9e92df94afb8eef8dae0a41a9c1654863607874/priv/templates/phx.gen.auth/registration_controller.ex#L24

I know, all requirements are somehow special and that's why you created this project. Thank you for that - I learned a lot about it!

I just was wondering if there are any special considerations about logging in right away after registration.

Kind regards and thank you for this template! Martin

josevalim commented 3 years ago

You can remove the login call if you prefer and then add a check where the user cannot login until he confirms his e-mail. Or alternatively, allow him to access only part of the application until he confirms.

The reason why we login after registration without confirmation is because that may be a better experience in many cases. If you ask users to wait for an e-mail to arrive... they may lose interest and go elsewhere.

marschro commented 3 years ago

Perfect - after thinking about it a bit longer, I totally agree about the user experience aspect. I keep your approach and will provide the functionalities by checking if the user has already confirmed or is in certain user-group. Thank you @josevalim 👍 - Elixir changed my live!