Skip to content

Commit

Permalink
Merge pull request #59 from Saca-la-Bici/RBACRutas
Browse files Browse the repository at this point in the history
feat: Cambios  RBAC en backend de rutas
  • Loading branch information
Zathiald authored Sep 29, 2024
2 parents 03296a0 + 2480732 commit 5a735ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 10 additions & 2 deletions modules/mapa/controllers/consultarMapa.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ const Ruta = require('../../../models/ruta/ruta.model');
exports.getRutas = async (req, res) => {
try {
const rutas = await Ruta.find({});
res.json(rutas); // Devuelve solo la lista de rutas

// Devolver las rutas junto con los permisos del usuario
res.status(200).json({
rutas: rutas,
permisos: req.permisos // Aquí devuelves los permisos
});
} catch (error) {
res.status(500).json({ message: 'Error al obtener las rutas', error });
}
Expand All @@ -18,7 +23,10 @@ exports.getRuta = async (req, res) => {
return res.status(404).json({ message: 'Ruta no encontrada' });
}

res.json(ruta);
res.status(200).json({
ruta: ruta,
permisos: req.permisos // Aquí devuelves los permisos
});
} catch (error) {
res.status(500).json({ message: 'Error al obtener la ruta', error });
}
Expand Down
7 changes: 4 additions & 3 deletions modules/mapa/routes/consultarMapa.routes.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const express = require('express');
const router = express.Router();
const verifyUserToken = require('../../../util/verifyUserToken');
const verifyUserPermissions = require('../../../util/verifyUserPermissions');

const consultarMapaController = require('../controllers/consultarMapa.controller');
const consultarMapaController = require('../controllers/consultarMapa.controller');

router.get('/',verifyUserToken,consultarMapaController.getRutas);
router.get('/',verifyUserToken, verifyUserPermissions,consultarMapaController.getRutas);

router.get('/:id', verifyUserToken, consultarMapaController.getRuta);
router.get('/:id', verifyUserToken, verifyUserPermissions, consultarMapaController.getRuta);

module.exports = router;

0 comments on commit 5a735ef

Please sign in to comment.