hiteshchoudhary / chai-backend

A video series on chai aur code youtube channel
4.18k stars 624 forks source link

Feature Request: Implement Email Link, Mobile OTP Verification, and Google Account Login #29

Open kumaraswini-11 opened 7 months ago

kumaraswini-11 commented 7 months ago

How can we implement email link or mobile OTP verification at the time of registration? If, later, we want, we can also implement this for two-factor authentication on the settings page.

Also, if someone wants to log in using their Google account, how do we implement that?

If you could implement this in the ongoing project, that would be great. Otherwise, please provide some ideas or explanations on how to implement this.

Divyanshu7001 commented 7 months ago

A email OTP verification can be done easily with NodeMailer...which is used to send the email from your account to the registering user's account. The email can have a 4 digit or 6 digit random otp that you will generate with the logic from Math package. The verification code actually has to be generated before do the procedure for user.create..as the verification code will be put in there for that perticular user. As the user gets the email & enters the otp from front-end(supposing in a form)...it will be taken & matched with a simple if logic...if it mactches..then we can just change the isVerified or some other state as you desire to be true.

saheemshafi commented 7 months ago

I have implemented it in typescript. It might be helpful for reference. https://github.com/saheemshafi/void_video/blob/main/apps/server/src/utils/email.ts https://github.com/saheemshafi/void_video/blob/main/apps/server/src/utils/create-email-template.ts