Tuesday, 14 March 2017

Best practice email confirmation in MEAN app?

What is the best email confirmation flow for user and for app?

Some variants:

a) The most simple variant, but not the best.

  1. User send signup form.
  2. On backend I send link with random hash to users email. In parallel I save this user to db with the active:false, hash: hash fields.
  3. user click link
  4. on backend I check link for hash, try to find user with hash. If user found in db, I change active to true.

    Flaw: What if email isn't correct or error happened during send? How I can handle it? I can't

b) We can handle all errors and display it to user, but very slow variant

  1. User send signup form.
  2. On backend the first of all I save this user to db, then I send link with random hash to users email and if it was sent correctly( no errors) only then, I send response.
  3. if error happens, I send error response to client, so he know that letter didn't send.
  4. probably, I need to delete this user from db

    Flaw: Process of registration is really slow. It takes about 20 seconds

c) The best variant, I think

  1. User send signup form.
  2. On backend I save the user to db.
  3. If no errors, I send response to user. In parralell send link with random hash to users email.
  4. user get response, if no errors , redirected to page e.g. /last-step with text check your email... Also on this page I'll show link, which will allow to send email confirmation again (e.g. every 3 mins)

    Question: How I can recongize on backend from whom this link was clicked? Where to store temporary info about this user on client?



via WhatIsHTML

No comments:

Post a Comment