Authentication of user registration by email in Node.js

Asked

Viewed 1,383 times

0

I am developing a user registration screen, and arose the need to authenticate the user registration by email, the procedure would be something like, when confirming the registration an email is triggered to the user, and the same to complete the procedure would have to access your e-mail and click on the confirmation url. Does anyone have any suggestions on how to do it, or does anyone know of any example to indicate? Grateful.

  • My colleagues Natan and Felipe Borges will help me, Gratefully.

2 answers

2


Your doubt is a little vague as to where you are.

  1. Registration in the database was performed?
  2. Can send e-mail?

I am assuming that you have a record in the database and can send emails. Do the following:

  1. In the registered user table, create an "checked" name field of type int and assign 0 to unchecked and 1 to checked. By default all registrations will have the value 0
  2. add in the register table a field called "token" of the varchar type
  3. each new registration that is made, generate a unique token of type UUID
  4. Send an email registration activation link to your user. Example of activation link: http://www.seusite.com/ativacao?token=TOKEN_EXCLUSIVO_DO_USUARIO
  5. The above address will read to query string token and will check if there is any record that matches the token. If there is, change the "checked" field to 1

I imagine you have a login screen. In this login screen you get the user credentials (login and password). You must grant access only to users who have the "verified" field equal to 1.

I hope it helped.

  • The registration of users has already been done, and I will implement the part of sending emails. Your suggestion already helps me a lot! Thanks.

  • Glad you could help. If this is the solution, mark my answer as accepted.

1

  • Thanks for the tip!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.