The goal of this project is to build a complete set of authentication APIs that include functionalities for user login, signup, password recovery, and token management.
Backend: Express.js - A web application framework for Node.js.
Database: MongoDB - A NoSQL database for storing user data and tokens.
-
Login API Allows users to authenticate with their credentials (email & password). Returns an access token and refresh token upon successful authentication.
-
Signup API Allows new users to register by providing their details (e.g., name, email, password). Hashes the password for security before storing it in the database.
-
Forgot Password API Enables users to request a password reset if they’ve forgotten their password. Sends an email with a reset link/token for password recovery.
-
Reset Password API Users can set a new password using the token provided in the forgot password flow. Validates the token and ensures it hasn’t expired before allowing the password reset.
-
Token Management Access Token: Short-lived tokens used for authenticating API requests. Refresh Token: Longer-lived tokens used to generate new access tokens without requiring the user to log in again. Tokens are securely managed and stored in the database with expiration times.
- Clone the repository
git clone https://github.com/hb99960/Coders-Boutique.git
- Navigate into the project directory:
cd backend
- Create a .env file in the root directory and add your environment variables:
PORT=3000
MONGO_URI=your_mongodb_uri
JWT_SECRET=your_jwt_secret
NODE_ENV=development
EMAIL_USER=your_email
EMAIL_PASS=your_email_password
- Start the development server:
npm run dev
- The API will be available at http://localhost:3000/api/auth
-
Signup
POST
http://localhost:3000/api/auth/signup
-
Logout
POST
http://localhost:3000/api/auth/logout
-
Login
POST
http://localhost:3000/api/auth/login
-
Forget Password
POST
http://localhost:3000/api/auth/forgot-password
-
Reset Password
POST
http://localhost:3000/api/auth/reset/:token
-
Reset Form
GET
http://localhost:3000/api/auth/reset-password/:token