me-imfhd / turbocell

Load the turbocell and execute your idea.
https://turbocell-web.vercel.app
5 stars 0 forks source link

Add Profile Page and Email Verification #3

Open rehan-adi opened 2 weeks ago

rehan-adi commented 2 weeks ago

Description: Currently, the project includes signin and logout functionality but lacks a signup feature. A signup page is essential for new users to create accounts. To enhance security, I propose implementing email verification during the signup process.

  1. Frontend:

    • Develop a signup form with fields for email, username, and password.
    • Integrate form validation using React and Zod.
  2. Backend:

    • Create a signup route that handles new user registration.
    • Use bcrypt for password hashing and Prisma for database interaction.
    • Implement email verification using Resend, sending a verification email upon signup.
    • Store a verification code in the database with an expiration timestamp.
    • Add validation for user input to prevent invalid data submission.
  3. Security:

    • Integrate JWT for generating secure tokens.
    • Implement checks to ensure the user verifies their email before gaining full access to the application.
me-imfhd commented 2 weeks ago

Turbocell is using next-auth heavily, we don't need extra sign up next-auth takes care of it, sign-in creates an account if does not already exist in the database.

We need to implement a /profile page to handle email verification. Since next-auth manages sign-ups and sign-ins, our focus is on allowing users to verify their email addresses post-login with OAuth (Google/Discord).

On the /profile page, provide an option for users to request email verification. This will involve sending a verification email to the user. Once the user verifies their email, update the emailVerified field in the database (emailVerified DateTime?) to reflect this change. A null value indicates that the email has not been verified yet.

Ensure that after verification, the emailVerified field is populated with the current date and time to confirm successful verification.

https://github.com/me-imfhd/turbocell/blob/main/packages/db/prisma/schema.prisma#L65 You can query this to check user is verified or not.