added refresh token authorization

This commit is contained in:
Pau 2025-04-07 23:24:28 +02:00
parent 1e59a5a33a
commit faa93e1d71
1 changed files with 14 additions and 1 deletions

View File

@ -35,6 +35,18 @@ const authenticateToken = (req, res, next) => {
}); });
}; };
const refreshAuthenticate = (req, res, next) => {
const token = req.body.refreshToken
getDataFromToken(token)
.then((decoded) => {
req.auth = decoded;
next();
})
.catch((error) => {
return sendResponseUnauthorized(res, error);
});
}
const authorizePermission = (endpoint) => { const authorizePermission = (endpoint) => {
return (req, res, next, config) => { return (req, res, next, config) => {
obtainToken(req, res) obtainToken(req, res)
@ -90,5 +102,6 @@ const _getRolePermissionsByName = (roleName, config) => {
export { export {
authenticateToken, authenticateToken,
authorizePermission, authorizePermission,
setToken setToken,
refreshAuthenticate
}; };