Skip to content

UUID API

siddharthakonakanchi edited this page Dec 5, 2017 · 2 revisions

UUID

  1. Description
  2. Installation
  3. API calls using package
  4. Code Snippet
  5. Database Insertion
  6. Reference

UUID

Description

A universal unique identifier (UUID) is a standard of generating identifiers, standardized by the Open Software Foundation (OSF).

The intent of UUIDs is to be able to generate unique identifiers in a distributed system UUID is meant for generating UUIDs from truly-random or pseudo-random unique numbers.

Installation

npm install uuid

Usage in our project

In our application once the user is logged in, each subsequent request to a page will internally call the JWT, allowing the user to access routes, services, and resources that are permitted with that token. Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains. In order to generate the random number unique value and pass to the URL of forget password

API Calls using package

/users/forgot Here we are generating unique random number by using UUID API

/users/reset/:token(GET) Generated token is passed as a parameter request to the forgot mail /users/reset/:token(POST) The same UUID is sent to update the password to corresponding user

Code Snippet

/users/forget

                    const token = uuidv4();
                        console.log(token);
                        let mailOptions = 

/users/reset/:token(GET) Use token and send to URL of mail /users/reset/:token(POST) Use the generated token to keep get details of the user and update password

Database Insertion

Insert into the token table generated token and 4 digit user id

ReferenceUUID API

More information can be obtained from https://www.npmjs.com/package/uuid

Clone this wiki locally