Commit ec6e07ef authored by Rodrigo Garcia Saenz's avatar Rodrigo Garcia Saenz

Agregando endpoint para listado de logs en sistema de archivos

parent cb851375
'use strict';
const debug = require('debug')('app:controller:auth');
const config = require('../../../../common/config');
module.exports = function setupAuthController (services) {
const { AuthService, UsuarioService } = services;
......@@ -23,6 +24,10 @@ module.exports = function setupAuthController (services) {
}
user = user.data;
respuesta = await UsuarioService.getResponse(user, req.ipInfo);
// adicional para el modulo logs
if (respuesta.permisos.hasOwnProperty('logs:read')) {
respuesta.logsType = config.logs.storage;
}
} catch (e) {
return next(e);
}
......
'use strict';
const debug = require('debug')('app:controller:token');
const { userData, generateTokenInfinite } = require('../../../lib/auth');
module.exports = function setupLogsController (services) {
const { TokenService, Log } = services;
async function listarLogs (req, res, next) {
debug('listando logs (sistema de archivos)');
let user = await userData(req, services);
let data = req.body;
try {
let result = await Log.findAll(data);
// res.send({
// count: result.data.count,
// datos: {
// logs: result.data.rows
// }
// });
res.send({
datos: {
coung: result.data.count,
datos: result.data.rows
}
});
} catch (e) {
return next(e);
}
};
return {
listarLogs
};
};
'use strict';
const guard = require('express-jwt-permissions')();
module.exports = function setupUsuario (api, controllers) {
const { LogsController } = controllers;
api.get('/logs/listar', guard.check(['logs:read']), LogsController.listarLogs);
return api;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment