api-secure-databank/config/services.js

14 lines
344 B
JavaScript
Raw Normal View History

2023-06-18 18:46:04 +00:00
const jwt = require('jwt-simple');
const moment = require('moment');
const config = require('./config');
exports.createToken = function(user, TFA) {
var payload = {
sub: user,
TFA: TFA,
iat: moment().unix(),
exp: moment().add(5, 'm').unix(), //5 minutillos
};
return jwt.encode(payload, config.TOKEN_SECRET, 'HS512');
};