Source Code: Repository -> twilio-verify-test
Author: Juanes Quintero -> GitLab / GitHub
This project is a web focused clone of yafuquen/twilio-verify-example, review the documentation there for more information about Twilio.
This project can be run it by installing Node.js <= 18.14 and Docker >= 24.0.6 (if you prefer to use the DB directly in your local machine you can skip the Docker requirement).
Docker
https://www.docker.com/resources/what-container
https://www.docker.com/get-started
Node.js
https://nodejs.org/en/download
Clone the repository. Then, install dependencies with
npm install
Create a .env file from an example template, do the following in your Terminal
cp .env.sample .env
To run the application, you'll need set up your Twilio account credentials and configure the Verify Service, so you’ll need to collect the following variables from the Twilio Account Portal.
TWILIO_ACCOUNT_SID
TWILIO_AUTH_TOKEN
TWILIO_VERIFY_SERVICE_SID
for more information go to base repo and review docs
Also you will need to set up the following MongoDB env variables
MONGO_DBNAME=
MONGO_USER=
MONGO_PSSWD=
MONGO_PORT=
Start the application in development mode
$ npm run dev
This command will star first the 2 Mongodb containers based on the docker-compose.yml file behind with...
$ docker compose up -d
...then it will run the Express.js app with...
$ nodemon index.js
One container is for the database server and the other one for a UI db management tool.
If you install the mongodb server outside Docker please use...
$ npm start
...this will just run the Express server, ensure your mongo service is up and running.
Express.js app now should be running at http://localhost:5000/
Mongo Express GUI on http://localhost:8081
MongoDB sevrer Database on localhost:27017
Verify API process
- User receives a sms/wpp message with OTP code.
- User types/enters the OTP code.
- Verifies the code against the Verify API, to authorize user.
Register on http://localhost:5000/register form, with following fields: username, password, phone number and enable 2FA or not.
If 2FA checked and phone entered:
- verifies user with Verify API.
- register request completed
else create new user directly.
A registred user can LogIn at http://localhost:5000/login form with following fields: username, password.
If 2FA enabled:
- verifies user with Verify API.
- login request completed
else open user session directly.
A loggedin user can change password at http://localhost:5000/profile/change-password
If 2FA enabled:
- verifies user with Verify API.
- change password request completed with message.
else change password directly.
MIT