A simple backend authentication system with sign-up and sign-in functionality.
- User Registration (Sign-Up)
- User Authentication (Sign-In)
- Password Hashing
- JSON Web Token (JWT) Authentication
- Form Validation
- Basic Logging
- MongoDB Database Integration
Before you begin, ensure you have the following installed:
-
Clone the repository:
git clone https://github.com/yourusername/basic-auth-system.git cd basic-auth-system -
Install dependencies:
npm install -
Start MongoDB:
- For Windows: Start the MongoDB service
- For Mac/Linux: Run
mongodin a terminal
-
Start the application:
npm start
For testing purposes, you can use the following credentials:
- Email: test@example.com
- Password: Test@123
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"
}Make a POST request to /api/auth/signin with the following JSON body:
{
"email": "test@example.com",
"password": "Test@123"
}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.
POST /api/auth/signup- Register a new userPOST /api/auth/signin- Authenticate a userGET /api/auth/me- Get the current user's details (Protected route)
- Minimum 8 characters
- At least 1 uppercase letter
- At least 1 lowercase letter
- At least 1 number
- At least 1 special character