Adding SignIn with Email to BOLT.FUN

0 sats
0 comments

I'm currently working on a new feature for BOLT.FUN which is signing in with email.

This is just a quick spec for how the intended User flow looks & how I will be implementing it technically.

User Flow

1- On the login page, the user clicks on "Sign In with Email"

2- The user is taken to a page where he is asked to input his email

3- After inputting his email, he is taken to a page to input an OTP, & an email with this OTP is sent to his inbox.

4- Upon correct entry of the OTP, the user is signed in & redirected to the home page

Technical Flow

- When the user inputs his email & clicks "sign in", on the backend:

1- we generate an OTP

2- we call the queue service to send an email with the OTP

3- we store the email+OTP in the DB (+ expiry date)

After the user submits the OTB with the email

1- we check the DB to validate OTB + Email

2- We delete this entry

3 We have a UserEmail Table where the primary field is emails, & we have a relation to "users ids"

4- We check this UserEmail table to see if we already have a user for this email:

--> Yes (Sign In)

We generate a jwt token with this user's id in it, & set it as a cookie, return

--> No (Sign Up)

--- We create a new user entry

--- We create a new UserEmail entry

--- We generate a jwt token with this user's id in it & return as cookie.

How to link an email as a backup method for existing accounts?

- From a profile settings page, the user submits an email + OTP + userId to the '/link-email' endpoint

- We check the DB to validate OTB + Email

- We delete this entry

- We check the UserEmail DB

- If we already have a user connected to this email, we delete it

- We create a new entry for this user-email

I'm a passionate Front End developer with a love for building unique things. I love a good challenge and am always looking to do stuff that I haven't done before.

Related Project

BOLT🔩FUN

BOLT🔩FUN

Tags