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

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
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
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
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 42716 114
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement