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'); };