A simple Node.js application demonstrating password reset functionality using email verification.
Note: This repository is intended as a personal learning exercise to explore backend authentication patterns.
- User registration with password hashing
- Password reset via email verification
- Time-limited reset tokens (1 hour)
- MongoDB integration for user data storage
- Node.js with Express for the backend server
- MongoDB with Mongoose for database operations
- Nodemailer for sending password reset emails
- bcrypt for secure password hashing
- crypto for generating reset tokens
- Node.js
- MongoDB database (local or Atlas)
- Gmail account for sending emails
-
Clone the repository
git clone https://github.com/DanielPodolsky/Forgot-Password-Exercise.git cd Forgot-Password-Exercise -
Install dependencies
npm install -
Create a
.envfile in the root directory with the following variables:MONGODB_USERNAME=your_mongodb_username MONGODB_PASSWORD=your_mongodb_password MONGODB_CLUSTER=your_cluster_address MONGODB_OPTIONS=retryWrites=true&w=majority GMAIL_MAIL=your_gmail_address GMAIL_PASSWORD=your_app_password -
Start the server
nodemon app.js
- POST /api/auth/register - Register a new user
- POST /api/auth/forgot-password - Request password reset email
- POST /api/auth/forgot-password/:token - Reset password with token