✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
El middleware autorizarRol verifica si el rol está incluido en el array de roles permitidos y si no lo está, retorna una respuesta con código 403 y un mensaje derror
export const autorizarRol = (rolesPermitidos) => { return (req, res, next) => { if (!rolesPermitidos.includes(req.user.role)) { return res.status(403).json({ message: "No tienes permiso para acceder a esta ruta" }); } next(); }}Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!