A project demonstrating the 2 factor authentication process for login system.
- Username and password as first verification step.
- OTP based verification.
API used : twilio (to send OTP to registered mobile number)
- Username password authentication
- OTP based verification
- Reset password by link sent to email on forgot password
- Change password from dashboard.
- Edit user details
- Mobile number verification status
- Option to switch ON or OFF OTP verification.
-
Node.js (https://nodejs.org/en/download/)
-
mongoDB (https://www.mongodb.com/download-center/community?tck=docs_server)
-
npm (inside node.js to install packages)
(installation guide : https://www.guru99.com/download-install-node-js.html) -
using npm install necessary packages mentioned in package.json or run : npm install
-
Setup other requirements
- gmail account : to send mail as admin when user click forgot password
(Replace details in configure.js in configure directory with gmail details) - twilio account : to send message using their API to send OTP
(After creating twilio account purchase a number using free credits available. Then copy paste accountSID, serviceID,phone and authToken in configure.js)
(Note : If you are using twilio trial account so numbers we send OTP to must be verified in console at twilio account dashboard.)
- gmail account : to send mail as admin when user click forgot password
- node app.js
create a configure.js file in configure directory with following structure
module.exports = {
twilio: {
serviceID: 'your serviceID here',
accountSID: 'your accountSID here',
authToken: 'your authToken here',
},
adminmail: {
service: 'service provider eg:gmail',
auth: {
user: 'your username here',
pass: 'your password here'
}
}
}