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
406 B
JavaScript

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