3.0.1 • Published 3 years ago

tenantapp-authentication v3.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

tenantapp-authentication

This package provides features to authenticate users and perform other authentication related procedure in tenantApp. it exports 3 functions namely:

  • generateToken (obj)
  • verifyToken ()
  • extractDataFromToken ( dataToBeRecovered, token )

Installation

To install, use the command below

npm install tenantapp-authentication

Usage

Generate Token

const { generateToken } = require('tenantapp-authentication');

const token = generateToken({your payload});

Verify Token

const { verifyToken } = require('tenantapp-authentication');

Then use the verifyToken variable as a middleware in your routes e.g:

router.get('/get-user-by-username/:username', verifyToken, View.getUserByUsername);

Extract Data from a token

To extract one of the data you encoded using generateToken function, follow this steps:

const { extractDataFromToken } = require("tenantapp-authentication");

const data = extractDataFromToken('userId', token);

very easy, right? that's all you have to do.

NOTE:

You have to configure the token secret key before you can use this package; to do this, set TOKEN_SECRET_KEY variable in your .env file to a desired value

3.0.1

3 years ago

3.0.0

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago