Skip to content

Commit

Permalink
fix: add role
Browse files Browse the repository at this point in the history
  • Loading branch information
Beor18 committed Aug 5, 2019
1 parent 5929625 commit f4017c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 1 addition & 9 deletions app.js
Expand Up @@ -11,8 +11,6 @@ const cors = require('cors');
const rutasSeguras = require('./routes/rutas-seguras');
const users = require('./routes/user');

const user = require('./models/User');

const { getLogger, logHandler, terminate } = require('@jwt/utils');
require('./config/passport')(passport);

Expand Down Expand Up @@ -44,13 +42,7 @@ app.disable('etag');
app.disable('x-powered-by');

app.get('/', (req, res) => {
if (req.user.role === 'administrador') {
res.send('Hola api rest de Peliculas! creado por Fernando López y Logan');
} else {
res.status(404).json({
mensaje: 'Ups! Sin permisos. Por favor sea admin.'
});
}
res.send('Hola api rest de Peliculas! creado por Fernando López y Logan');
});

if (!module.parent) {
Expand Down
10 changes: 10 additions & 0 deletions controllers/pelicula.controller.js
Expand Up @@ -128,6 +128,16 @@ async function filtroEstrella(req, res) {
}
}

async function rutaPruebaRole(req, res) {
if (req.user.role === 'administrador') {
res.send('Hola api rest de Peliculas! creado por Fernando López y Logan');
} else {
res.status(404).json({
mensaje: 'Ups! Sin permisos. Por favor sea admin.'
});
}
}

module.exports = {
getPeliculas,
getPeliculaPorId,
Expand Down

0 comments on commit f4017c8

Please sign in to comment.