You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
planka_custom/server/api/helpers/verify-token.js

29 lines
418 B
JavaScript

const jwt = require('jsonwebtoken');
module.exports = {
sync: true,
inputs: {
token: {
type: 'string',
required: true
}
},
exits: {
notValid: {}
},
fn: function(inputs, exits) {
let payload;
try {
payload = jwt.verify(inputs.token, sails.config.session.secret);
} catch (unusedError) {
throw 'notValid';
}
return exits.success(payload);
}
};