This project now includes a complete authentication system with MongoDB integration and email notifications.
- User registration and login
- Role-based access (Customer/Admin)
- JWT token authentication
- Email notifications with Nodemailer
- Admin dashboard for inventory management
- Secure password hashing with bcrypt
- Environment Variables
Create a
.env.localfile with the following variables:MONGODB_URI=mongodb://localhost:27017/walmart-ecomart JWT_SECRET=your-super-secret-jwt-key EMAIL_USER=amankumarsingh.org@gmail.com EMAIL_PASS=your-app-specific-password SESSION_SECRET=your-session-secret-key BASE_URL=http://localhost:3000 - MongoDB Setup
- Install MongoDB locally or use MongoDB Atlas
- Update the MONGODB_URI in your .env.local file
- Email Setup
- Enable 2-factor authentication on your Gmail account
- Generate an app-specific password for nodemailer
- Update EMAIL_PASS with your app-specific password
- Install Dependencies
npm install
- Run the Application
npm run dev
- Registration: Visit
/auth/registerto create a new account - Login: Visit
/auth/loginto sign in - Admin Access: Create an account with role "admin" to access
/admin/dashboard - Customer Access: Regular users can access the main shopping interface
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/verify- Token verification
Users receive welcome emails upon successful registration with:
- Account confirmation
- Role-specific welcome message
- Feature overview
- Getting started guide