Skip to content

Commit

Permalink
Seccion 15 Terminada
Browse files Browse the repository at this point in the history
  • Loading branch information
estudiobarragan committed Oct 20, 2019
1 parent 37161fa commit 343584e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 5 deletions.
8 changes: 8 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ var bodyParser = require('body-parser');
// Inicializar variables
var app = express();

// CORS
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS");
next();
});

// Body Parser
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
Expand Down
2 changes: 1 addition & 1 deletion routes/busqueda.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function buscarMedicos(busqueda, regex) {
function buscarUsuarios(busqueda, regex) {
return new Promise((resolve, reject) => {
Usuario.find({}, 'nombre correo rol')
.or([{ 'nombre': regex }, { 'email': regex }])
.or([{ 'nombre': regex }, { 'correo': regex }])
.exec((err, usuarios) => {
if (err) {
reject('Error al buscar usuarios: ', err);
Expand Down
12 changes: 8 additions & 4 deletions routes/usuario.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ app.get('/', (req, res, next) => {
var desde = req.query.desde || 0;
desde = Number(desde);

Usuario.find({}, 'nombre correo img role')
Usuario.find({}, 'nombre correo img role google')
.skip(desde)
.limit(5)
.exec((err, usuario) => {
Expand Down Expand Up @@ -89,7 +89,7 @@ app.put('/:id', mdAutenticacion.verificaToken, (req, res) => {
return res.status(200).send({
ok: true,
usuario: usuarioGrabado,
usuarioToken: req.usuario
usuario_actualizante: req.usuario
});
})
})
Expand All @@ -98,12 +98,16 @@ app.put('/:id', mdAutenticacion.verificaToken, (req, res) => {
/*
Crear un usuario
quito , mdAutenticacion.verificaToken con lo cual habilito el registro abierto
TODO agregar un campo habilitado que habilita las cuentas y hasta que no este asi indicado,
no pueden comenzar a trabajar.
*/
app.post('/', mdAutenticacion.verificaToken, (req, res) => {
app.post('/', (req, res) => {
/* var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync("B4c0/\/", salt); */
console.log(req);

var body = req.body;
var usuario = new Usuario({
nombre: body.nombre,
Expand Down
Binary file added uploads/usuarios/5dabbc4cf8fc301b4c8b7df4-421.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploads/usuarios/5dacb1023abc6a15e82eff5a-660.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploads/usuarios/5dacb1103abc6a15e82eff5c-63.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploads/usuarios/5dacb1163abc6a15e82eff5d-353.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploads/usuarios/5dacb11d3abc6a15e82eff5e-227.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 343584e

Please sign in to comment.