Auth using OTP
Friday 15 December 2023

Auth-using-OTP

  1. Description

  2. GitHub repo

  3. Postman Collection APIs

  4. Postman Collection Json

  5. How to run

  6. APIs

  7. ERD

Description

Auth-using-OTP is a project developed using Node.js, Express, and Sequelize. It provides an authentication system with OTP (One-Time Password) functionality. The project includes APIs for user registration, login, and verification.

How to run

  1. clone the repo
1git clone https://github.com/Adosh74/Auth-using-OTP
  1. change directory
1cd Auth-using-OTP
  1. install dependencies
1npm install
  1. open your DBMS and create database on mySql
1   create DATABASE auth_using_otp;
  1. create new file called .env like .env.example and fill all configurations

  2. import How Found Us data using

1npm run import:data
  1. run the server and test APIs
1npm run start

APIs

/api/register [POST]

body:

1{
2    "firstName": "newUser",
3    "lastName": "two",
4    "password": "test1234",
5    "mobile": "011111",
6    "age": 22,
7    "howFoundUs_id": 1
8}

api/login [POST]

body:

1{
2    "user_id": 1,
3    "otp": ":otp from sms or database:"
4}

/api/verify [POST]

body:

1{
2    "user_id": 1,
3    "otp": ":otp from sms or database:"
4}

ERD

users:

Column Type Validation/Options
id INTEGER Auto Increment, Primary Key
firstName STRING Required
lastName STRING Required
age INTEGER Required
howFoundUs_id INTEGER Required, References ‘howFoundUs’ model, ‘User’ must be found in ‘howFoundUs’ model
verified_boolean BOOLEAN Required, Default: false
mobile STRING Required
password STRING Required
createdAt DATE Required, Default: Current date

OTP:

Column Type Validation/Options
id INTEGER Auto Increment, Primary Key
user_id INTEGER Required, References ‘users’ model, ‘id’ must be found in ‘users’ model with CASCADE onDelete and onUpdate
OTP STRING Required
status ENUM Values: ‘used’, ‘unused’, Default: ‘unused’, Required
createdAt DATE Default: Current date, Required

howFoundUs:

Column Type Validation/Options
id INTEGER Primary Key
value STRING Required, Unique

Backlinks