Node.js Project to Implement 2 Factor OTP Code Authentication For Verifying Emails in Browser Using Javascript

 

 

two-step-auth

This is a npm package that helps in verifying an Email address by sending OTP

Installation

What It Does

For people developing login sections they must know if the email Id the end user provides is valid, thus this package takes in the Email ID they provide and returns you a data OTP to verify them, and sends the client one via Email, Thus making sure only verified Emails are encouraged.

General Default Usage

Kindly Provide a Company Name so the mail will be treated as important, but you can continue without it also,
Usually the server responds within seconds ~ =< 2 seconds, incase the server is inactive it might take upto ~ <= 10 seconds, And you can handle the Time you need the OTP to be valid from your project in your script and do the necessary 🙂

Custom Mail ID Usage

Kindly enable less secure apps in the link provided below, with your mail ID that you plan to use, and enable it! This will use your email ID and password to send mails to the client. Kind note we never store your passwords, and email Ids, we just transfer messages and logout 🙂

Steps

  • Pull in the LoginCredentials object from the package, and change the following, And they should be added before calling the Auth function (only for custom mail ID)
    • LoginCredentials.mailID = “Your mail ID”
    • LoginCredentials.password = “Your Password”
    • LoginCredentials.use = true

you will get a error message, if less secure apps is not enabled

Output Format

The output will be a Javascript JSON object, making it easy to work

Email Sample

 

Leave a Reply