ankitbisen28 / Atelier

Letest web app for custom clothing, Using React vite and Nodejs
https://atelier-client.vercel.app/
0 stars 1 forks source link

Implement "Email Verification" Feature Using Nodemailer #6

Open ankitbisen28 opened 3 weeks ago

ankitbisen28 commented 3 weeks ago

Description:

We need to implement an "Email Verification" feature that ensures users verify their email addresses before they can log in. This feature should send a verification email to the user's registered email address with a verification link. We will use Nodemailer to set up an SMTP server for sending the emails.

Tasks:

  1. Update Registration Process:

    • [ ] Modify the registration endpoint to create a new user with an unverified status.
    • [ ] Generate a secure verification token and save it to the database with an expiration time.
  2. Setup Nodemailer:

    • [ ] Install Nodemailer: npm install nodemailer
    • [ ] Configure Nodemailer with SMTP settings (e.g., using Gmail, Mailgun, or any other SMTP service).
  3. Send Verification Email:

    • [ ] Create an email template for the verification email.
    • [ ] Use Nodemailer to send the email with the verification link, including the secure token in the link.
  4. Create Verification API Endpoint:

    • [ ] Create an API endpoint /api/auth/verify-email to handle email verification requests.
    • [ ] Validate the token and ensure it has not expired.
    • [ ] Update the user's status to verified if the token is valid.
  5. Update Login Process:

    • [ ] Modify the login endpoint to check if the user's email is verified.
    • [ ] Prevent login if the email is not verified and return an appropriate error message.
  6. Security Considerations:

    • [ ] Ensure the token is securely generated and stored.
    • [ ] Implement rate limiting on the verification endpoint to prevent abuse.
    • [ ] Ensure the verification link expires after a certain period (e.g., 24 hours).

Additional Information:

References:

Labels:


Please review the tasks and provide any feedback or additional requirements. Once approved, we can start working on this feature.