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.
1git clone https://github.com/Adosh74/Auth-using-OTP
1cd Auth-using-OTP
1npm install
1 create DATABASE auth_using_otp;
create new file called .env like .env.example and fill all configurations
import How Found Us data using
1npm run import:data
1npm run start
/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}
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 |