@@ -4,13 +4,12 @@ const bcrypt = require('bcrypt');
44const _ = require ( 'underscore' ) ;
55
66const Usuario = require ( '../models/usuario' ) ;
7+ const { verificaToken, verificaAdmin_Role } = require ( '../middlewares/autenticacion' ) ;
78
89const app = express ( ) ;
910
1011
11- app . get ( '/usuario' , function ( req , res ) {
12-
13-
12+ app . get ( '/usuario' , verificaToken , function ( req , res ) {
1413
1514 let desde = req . query . desde || 0 ;
1615 desde = Number ( desde ) ;
@@ -46,7 +45,7 @@ app.get('/usuario', function(req, res) {
4645
4746} ) ;
4847
49- app . post ( '/usuario' , function ( req , res ) {
48+ app . post ( '/usuario' , [ verificaToken , verificaAdmin_Role ] , function ( req , res ) {
5049
5150 let body = req . body ;
5251
@@ -78,7 +77,7 @@ app.post('/usuario', function(req, res) {
7877
7978} ) ;
8079
81- app . put ( '/usuario/:id' , function ( req , res ) {
80+ app . put ( '/usuario/:id' , [ verificaToken , verificaAdmin_Role ] , function ( req , res ) {
8281
8382 let id = req . params . id ;
8483 let body = _ . pick ( req . body , [ 'nombre' , 'email' , 'img' , 'role' , 'estado' ] ) ;
@@ -103,13 +102,10 @@ app.put('/usuario/:id', function(req, res) {
103102
104103} ) ;
105104
106- app . delete ( '/usuario/:id' , function ( req , res ) {
107-
105+ app . delete ( '/usuario/:id' , [ verificaToken , verificaAdmin_Role ] , function ( req , res ) {
108106
109107 let id = req . params . id ;
110108
111- // Usuario.findByIdAndRemove(id, (err, usuarioBorrado) => {
112-
113109 let cambiaEstado = {
114110 estado : false
115111 } ;
@@ -121,7 +117,7 @@ app.delete('/usuario/:id', function(req, res) {
121117 ok : false ,
122118 err
123119 } ) ;
124- } ;
120+ }
125121
126122 if ( ! usuarioBorrado ) {
127123 return res . status ( 400 ) . json ( {
0 commit comments