Skip to content

SoftwareDeveloper-dhruv/auth-system

Repository files navigation

Basic Authentication System

A simple backend authentication system with sign-up and sign-in functionality.

Features

  • User Registration (Sign-Up)
  • User Authentication (Sign-In)
  • Password Hashing
  • JSON Web Token (JWT) Authentication
  • Form Validation
  • Basic Logging
  • MongoDB Database Integration

Prerequisites

Before you begin, ensure you have the following installed:

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/basic-auth-system.git
    cd basic-auth-system
    
  2. Install dependencies:

    npm install
    
  3. Start MongoDB:

    • For Windows: Start the MongoDB service
    • For Mac/Linux: Run mongod in a terminal
  4. Start the application:

    npm start
    

Testing the API

Test User

For testing purposes, you can use the following credentials:

Sign-Up

Make a POST request to /api/auth/signup with the following JSON body:

{
  "name": "Test User",
  "email": "test@example.com",
  "mobile_number": "1234567890",
  "gender": "male",
  "password": "Test@123",
  "confirm_password": "Test@123"
}

Sign-In

Make a POST request to /api/auth/signin with the following JSON body:

{
  "email": "test@example.com",
  "password": "Test@123"
}

Access Dashboard

After successful sign-in, you will receive a JWT token. Store this token in localStorage and navigate to /dashboard to access the protected dashboard page.

API Endpoints

  • POST /api/auth/signup - Register a new user
  • POST /api/auth/signin - Authenticate a user
  • GET /api/auth/me - Get the current user's details (Protected route)

Password Requirements

  • Minimum 8 characters
  • At least 1 uppercase letter
  • At least 1 lowercase letter
  • At least 1 number
  • At least 1 special character

About

Basic authentication system using Node.js, Express, MongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published