Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OTP feature #81

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

piyush-gangrade
Copy link

PR #39

Add verifyOTP.jsx for sending and verifying OTP, and update Login.jsx and Signup.jsx accordingly.

Details: After users log in or sign up, they will navigate to the 'verify' route where they have to enter the OTP sent to their email. After submitting the OTP, if it is valid, a token will be sent to the user.

Screenshot (60)

add two new fields otpToken and otpExpiry in UserModel.js and two controller function for sending and verifying otp
Copy link

vercel bot commented May 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
elective-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 13, 2024 6:39pm

Copy link

netlify bot commented May 11, 2024

Deploy Preview for chipper-cucurucho-7e07f5 ready!

Name Link
🔨 Latest commit 490037b
🔍 Latest deploy log https://app.netlify.com/sites/chipper-cucurucho-7e07f5/deploys/66425e621424d70008a069b8
😎 Deploy Preview https://deploy-preview-81--chipper-cucurucho-7e07f5.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

gitguardian bot commented May 11, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Add VerifyOTP.jsx and update Login.jsx and SignUp.jsx so that after login and signup, the user navigates to the verify route, and an OTP is sent to the user's email. After entering the OTP, the user will be logged in
@JayeshYadav99
Copy link
Member

JayeshYadav99 commented May 12, 2024

@piyush-gangrade Send screen recording of running this pr on local and performing otp functionality

@piyush-gangrade
Copy link
Author

piyush-gangrade commented May 12, 2024

@JayeshYadav99

OTP.feature.video.mp4

@JayeshYadav99
Copy link
Member

@piyush-gangrade Remove otp verification from login only keep it in signup

@piyush-gangrade
Copy link
Author

@JayeshYadav99, the following changes have been made

@VinayakVispute
Copy link
Member

@piyush-gangrade Hello,

Your contribution looks good to me but there are 2 huge flows

  1. There is loophole that immediate attention. Users should not be able to bypass OTP verification simply not verifying the OPT as signup Page and logining in directly. As you can see in Video.

Keep user authentication data and OTPs in separate collections to prevent bypassing OTP verification during login.

Video_240513165500.mp4
  1. You OPT are stored in plain text in mongodb. So I think it should encrypted but its your take what you think is correct

image

@piyush-gangrade
Copy link
Author

ok, I'll fix this issue and update

update Signup.jsx, VeifyOTP.jsx, AuthController.js and AuthRoutes and add OtpModel.js and encrypt.js
@piyush-gangrade
Copy link
Author

piyush-gangrade commented May 13, 2024

Changes:

Additions:

  1. Added server/Models/OtpModel.js to save email, signature, publicKey, and createdAt.
  2. Added server/util/encrypt.js to generate privateKey and publicKey so that we can create a signature of data using privateKey and verify it using publicKey.

Updates:

  1. Updated Signup.jsx so that it can send an OTP and provide inputData to VerifyOTP.jsx with the help of the navigate state and location state.
  2. Updated the sendOtp function of AuthController.js to create an OTP document, save email, signature, and publicKey, and send an OTP to the given email.
  3. Updated VerifyOTP.jsx so that after submitting the OTP, it sends a request to the 'signup' API route with inputData and OTP.
  4. Updated the signup function of AuthController.js so that it first checks if the OTP is valid. If the OTP is valid, it allows the creation of a User and sends back a token
Change.OTP.feature.functionality.mp4

@VinayakVispute
Copy link
Member

@piyush-gangrade Cool , Since my exams are going on, So I was unable to do but I will make sure to give you update today.

@piyush-gangrade
Copy link
Author

Thank you! Could you also please add assignees and labels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants