1.1.1 • Published 4 years ago
sails-jwtauth v1.1.1
sails-jwtauth
JWT Auth logic for js.
Installation
$ npm install sails-jwtauth --save
Usage
Add a secret key in config file for the invironment you are currently working on. For exameple in the config/env/development.js file:
module.exports = {
secret: 'private key',
};
for creating a token:
const jwtauth = require('sails-jwtauth');
let token = await jwtauth.signToken(payload);
return res.json({
token: token,
});
for decoding a token:
const jwtauth = require('sails-jwtauth');
let decoded = await jwtauth.verifyToken(payload);
return res.json({
decodedToken: decoded,
});
## License
This module is available under the **MIT license**.