Skip to content

Latest commit

 

History

History
184 lines (169 loc) · 4.64 KB

File metadata and controls

184 lines (169 loc) · 4.64 KB

Authorisation and Secure Login API

Overview

This API provides endpoints and its functionalities related to authorisation and secure login of an user.

Base URL

The base URL for all endpoints is: http://localhost:3000

ENDPOINTS

1. Authenticate User

  • Method: POST
  • URL: /auth
  • Description: Authenticates the user's credentials
  • Request Body:
    {
        "username": "user123",
        "password": "secretpassword"
    }
  • Response:
    • Status Code: 200 OK
    • Body:
    {
        "message": "Authentication successful",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMTIzIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
    }
  • Example using Curl:
    curl -X POST \
         -H "Content-Type: application/json" \
         -d '{
             "username": "user123",
             "password": "secretpassword"
         }' \
         http://localhost:3000/auth

2. Create Account

  • Method: POST
  • URL: /auth/create
  • Description: Creates a new user account
  • Request Body:
    {
        "username": "newuser123",
        "email": "newuser@example.com",
        "password": "secretpassword",
        "phoneNumber": 1234567890,
        "delivery Address": {
                                "state": "New York",
                                "district": "New York",
                                "city": "New York",
                                "pincode": "10001",
                                "address_lane": "5678 Oak Avenue",
                                "landmark": "Next to Empire State Building"
                            }
    
    }
  • Response:
    • Status Code: 201 Created
    • Body:
    {
        "message": "Account created successfully",
        "user_id": "user123"
    }
  • Example using Curl:
    curl -X POST \
         -H "Content-Type: application/json" \
         -d '{
             "username": "newuser123",
             "email": "newuser@example.com",
             "password": "secretpassword",
             "phoneNumber": 1234567890,
            "delivery Address": {
                                    "state": "New York",
                                    "district": "New York",
                                    "city": "New York",
                                    "pincode": "10001",
                                    "address_lane": "5678 Oak Avenue",
                                    "landmark": "Next to Empire State Building"
                                }
         }' \
         http://localhost:3000/auth/create

3. Forgot Password apply

  • Method: POST
  • URL: /auth/forgot
  • Description: Initiates the password reset process for a user who has forgotten their password
  • Request Body:
    {
        "email": "user@example.com"
    }
  • Response:
    • Status Code: 200 OK
    • Body:
    {
        "message": "password reset OTP sent to user@example.com"
    }
  • Example using Curl:
    curl -X POST \
         -H "Content-Type: application/json" \
         -d '{"email": "user@example.com"}' \
         http://localhost:3000/auth/forgot

4. Forgot Password otp verification

  • Method: POST
  • URL: /auth/forgot/otp
  • Description: Initiates the password reset process for a user who has forgotten their password
  • Request Body:
    {
        "otp": "12345"
    }
  • Response:
    • Status Code: 200 OK
    • Body:
    {
        "message": "OTP accepted",
        "token":"<long auth token>"
    }
  • Example using Curl:
    curl -X POST \
         -H "Content-Type: application/json" \
         -d '{"email": "user@example.com"}' \
         http://localhost:3000/auth/forgot/otp

5. Forgot Password

  • Method: POST
  • URL: /auth/forgot/reset
  • Description: Initiates the password reset process for a user who has forgotten their password
  • Request Header:
    {
        "authentication":"<long auth token>"
    }
  • Request Body:
    {
        "new_passoword":"iAm@Home"
    }
  • Response:
    • Status Code: 200 OK
    • Body:
    {
        "message": "Password reset instructions sent to user@example.com"
    }
  • Example using Curl:
    curl -X POST \
         -H "Content-Type: application/json" \
         -d '{"email": "user@example.com"}' \
         http://localhost:3000/auth/forgot