antalvarenga
How to do an email check/confirmation/validation with Phoenix?
I’m rather new to the programming world, and I’ve searched for this for a while and haven’t found a solution yet.
Question is - How to do an email check/confirmation/validation with Phoenix? I was looking for something like sending a link to the email for confirmation, because it seems that that’s the way it’s done by virtually all websites/companies.
Most Liked
bobbypriambodo
Just want to add, because you said that you are rather new to the programming world…
The basic flow of confirming email address is as follows:
-
User registered into your app
-
Your app inserts the user into the DB (perhaps table
accountsor something) with averifiedfield set tofalseor0 -
Your app generates a verify token (usually some random string), and
-
inserts it into a database (another table, such as
verify_tokens) and the associated user ID -
constructs a verify link with the token and send it to the user (might also want to include the user ID in it)
-
The user receives the email and clicks on the link
-
In the handler, your app will:
-
check the request params and look up for a verify token belonging to the user ID in the DB and
-
if found, update the
verifiedfield of your user on tableaccounts
I hope that makes sense!
OvermindDL1
I’d definitely put it in the database! They may not get around to checking their email soon and the server could restart before then! o.O
bobbypriambodo
Dockyard (@alexgaribay
) has recently published a guide on how to do email verification. It’s similar to the basic flow I stated above, but with leveraging Phoenix.Token as a unique token generator and expiry checking, making it unnecessary to store the token in the DB. I think that’s a really neat and lean approach!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









