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

hariharasudhan94
I would like to know what is the best IDE for elixir development?
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
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New

We're in Beta

About us Mission Statement