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

fix: Implemented Account verification , Email validation. issue:#152 #155

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

kaali001
Copy link
Contributor

@kaali001 kaali001 commented Aug 6, 2024

Description

This PR implements email validation functionality in our application. The feature includes temporary user storage, token-based email verification, and user redirection upon successful verification. Below are the key details of the implementation:

Changes

1. Temporary User Storage:

  • When a new user signs up, their details are stored in a temporary database table (tempUser).
  • This ensures that only verified users are moved to the main user database (mainuser).

2. Token Generation and Email Sending:

  • A unique token is generated for each user upon signup.
  • An email with a verification link containing the token and user's email is sent to the user.

3. Email Verification Endpoint:

  • An API endpoint (/api/users/verify-email) is created to handle the verification process.
  • The endpoint validates the token and email, transfers the user details to the main user database if successful, and deletes the temporary entry.

4. Frontend Integration:

  • The VerifyEmail component fetches the token and email from the URL and calls the verification API.
  • On successful verification, the user is redirected to a success page with a "Login" button that redirects to the login page.

image
image
image

How to test

  • Ensure you have the backend server running on port 3000 and the frontend application running on port 5173.
  • Set up your email service correctly to send verification emails.
  • Make sure your Prisma Client is properly configured and the database is up and running.
  • Go to the signup page.
  • Fill in details (name, email, password, etc.).
  • Submit the form.
  • Check your email for a verification link.
  • Click the verification link in the email.
  • Verify you see "Your account has been verified successfully!" on the /verify-email page.
  • Ensure user details are in tempUser table initially.
  • After verification, check details are moved to mainuser table and removed from tempUser.

fix an issue already created in the repository-
#152

@dvjsharma
Copy link
Owner

A small suggestion- instead creating a new tempUser table and migrating data upon successful verification, you can add a new field isVerified in current main user table to handle the scenario. It will reduce database calls and will be more modular.

Copy link
Owner

@dvjsharma dvjsharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dvjsharma dvjsharma merged commit d6e8266 into dvjsharma:master Aug 7, 2024
2 checks passed
@dvjsharma dvjsharma added gssoc GSSoC'24 label Ready level2 labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants