ggarciajr

ggarciajr

POW API email confirmation flow

I’m trying to understand how to redirect users to /registration/edit after sign in / sign up when users haven’t confirmed their email.

I read through Pow API email confirmation flow and Resend email confirmation link | Pow

The powauth article is from 2020 and I don’t know if it is still the correct solution for what I’m trying to achieve.

Here is what I did so far:

Path 1 (suggested by the article linked above):

  • created the controller RegistrationController
  • included the post path in the router

Outcome: User get redirected to /session/new page and a flash message pops up

Path 2:

  • added a backend router and defined after_sign_in_path and after_registration_path to redirect users to a new page /verify-email where I can show the user a message explaining they need to verify their email first.
  • include a button with a link to resend the confirmation email
  • add /verify-email to an unprotected route

Outcome: User gets redirected to the /verify-email page, clicking the link sends the user to the right controller, but there is no current_user in the conn, because the route is not protected. User gets redirected to the /session/new page.

Path 3:

  • added a backend router and defined after_sign_in_path and after_registration_path to redirect users to a new page /verify-email where I can show the user a message explaining they need to verify their email first.
  • include a button with a link to resend the confirmation email
  • add /verify-email to a protected route

Outcome: User get redirected to /session/new page and a flash message pops up

My main questions are:

  1. Should I take path 2 and add the user email (entered in the sign in page) as a hidden field in the verify email page form and try to login the token from the db to resend the email? Even though both routes get (to show the page) and post to resend the email are not protected?

  2. Am I missing something on paths 1 and 3 and that’s why I don’t get redirected to the /registration/edit page after sign?

  3. If path 3 is the best one, do I need to implement my own RequireAuthenticated plug so I have more control and can redirected the user to the post /verify-email route when clicking the resend button?

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement