You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Comprobar si llega autorización
if (!req.headers.authorization) {
return res.status(403).send({
message: 'La petición no tiene la cabecera de authorization'
});
}
// Limpiar el token y quitar comillas
var token = req.headers.authorization.replace(/['"]+/g, '');
console.log(token);
console.log(secret);
var payload = jwt.decode(token, secret);
try {
// Decodificar token
var payload = jwt.decode(token, secret, false, 'HS256');
console.log(payload);
// Adjuntar usuario identificado a request
// req.user = payload;
// Pasar a la acción
// next();
// Comprobar si el token ha expirado
if (payload.exp <= moment(15 * 60).unix()) {
return res.status(404).send({
message: 'El token ha expirado'
});
}
} catch (ex) {
return res.status(404).send({
message: 'El token no es válido'
});
}
// Adjuntar usuario identificado a request
req.user = payload;
// Pasar a la acción
next();
};
I dont know how to fix it.
The text was updated successfully, but these errors were encountered:
I have an error signature verification failed
'use strict'
// const jwt = require('jsonwebtoken');
// const fs = require('fs');
var jwt = require('jwt-simple');
var moment = require('moment');
var secret = 'MIIEpAIBAAKCAQEAyVTQ9QxfutaYXKBbYfZbH2vhIWoIPEjAFSbsy1PZoIcclUQRhJ8t2m7v47M8eEyYd7EvXTNdoN6CDs0DoNC9KESATZV5SUVr7sk9pOcMrm0VryAdh7hQbbHWqyKmOehCt1JdX7gV2i5XnRb5qYQSyoB8sGdfR4SQ9q1XPRIpBP8RYXCP';
exports.authenticated = function(req, res, next) {
};
I dont know how to fix it.
The text was updated successfully, but these errors were encountered: