Skip to content

code-savant/Ecadamy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ecadamy Backend Project

Overview

The Ecadamy backend provides a set of APIs to manage user authentication and registration through OTP (One-Time Password) verification. It supports sending OTPs, verifying phone numbers, and user management functionalities such as registration and login.


Server Link

Base URL: https://ecadamy.onrender.com


api endpoints

1. Send OTP

  • Method: POST
  • Endpoint: {server}/api/otp/send
  • Purpose: Checks if the phone number exists in the database. If not, generates and sends an OTP to the specified phone number.
  • Request Body Example:
    {
        "phone": "+1234567890"
    }

2. Verify OTP

  • Method: POST
  • Endpoint: {server}/api/otp/verify
  • Purpose: Verifies the OTP sent to the phone number.
  • Request Body Example:
    {
        "phone": "+1234567890",
        "otp": "123456"
    }

3. Register User

  • Method: POST
  • Endpoint: {server}/api/users/register
  • Purpose: Allows new users to register their details in the database.
  • Request Body Example:
    {
        "firstName": "John",
        "lastName": "Doe",
        "classTitle": "Web Development",
        "email": "johndoe@example.com",
        "phone": "+1234567890",
        "password": "securepassword"
    }

4. Login in user

  • Method: POST
  • Endpoint: {server}/api/users/login
  • Purpose: Allows existing users to log in using their phone number and password.
  • Request Body Example:
    {
        "phone": "+1234567890",
        "password": "sample"
    }

5. Get user data

  • Method: GET
  • Endpoint: {server}/api/users/getUser
  • Purpose: Fetches the data of the logged in user.
  • Note: Make sure to include token in your headers when sending request. This token expires after 1h.
  • Request Body Example:
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${token}`
      }

User Object Structure

The user object returned by the API contains the following fields:

  1. _id - Unique identifier for the user.
  2. firstName - The user's first name.
  3. lastName - The user's last name.
  4. classTitle - The class or course associated with the user.
  5. email - The user's email address.
  6. phone - The user's phone number.

Note: Ignore user _id as this will be given to the user once registered on the database.

About

school backend authentication logic

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published