diff --git a/src/middlewares/auth.js b/src/middlewares/auth.js index 0628622..5403b7a 100644 --- a/src/middlewares/auth.js +++ b/src/middlewares/auth.js @@ -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) => { return (req, res, next, config) => { obtainToken(req, res) @@ -90,5 +102,6 @@ const _getRolePermissionsByName = (roleName, config) => { export { authenticateToken, authorizePermission, - setToken + setToken, + refreshAuthenticate }; \ No newline at end of file