Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2574b2bf86 | |||
| 0d0cc8f53d | |||
| 1c821addfb |
@@ -0,0 +1,20 @@
|
||||
const helperPath = '../../helper';
|
||||
const encriptar = require(`${helperPath}/encriptar`);
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const newAdmin = async (body) => {
|
||||
const password = encriptar.generarPassword();
|
||||
|
||||
|
||||
await Usuario.create({
|
||||
usuario: body.usuario,
|
||||
password: encriptar.encriptar(password),
|
||||
nombre: body.nombre,
|
||||
activo: true,
|
||||
idTipoUsuario: body.idTipoUsuario,
|
||||
})
|
||||
return password;
|
||||
};
|
||||
|
||||
module.exports = newAdmin;
|
||||
@@ -5,6 +5,7 @@ const route = '/usuario';
|
||||
const controllerPath = '../controller/Usuario';
|
||||
const escolares = require(`${controllerPath}/escolares`);
|
||||
const login = require(`${controllerPath}/login`);
|
||||
const newAdmin = require(`${controllerPath}/newUser`);
|
||||
const newPasswordAlumno = require(`${controllerPath}/newPasswordAlumno`);
|
||||
const newPasswordResponsable = require(`${controllerPath}/newPasswordResponsable`);
|
||||
const responsable = require(`${controllerPath}/responsable`);
|
||||
@@ -22,6 +23,17 @@ app.post(`${route}/login`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// POST
|
||||
app.post(`${route}/newAdmin`, (req, res) => {
|
||||
return newAdmin(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
// GET
|
||||
app.get(`${route}/escolares`, verificaToken, (req, res) => {
|
||||
return escolares(req.query)
|
||||
|
||||
Reference in New Issue
Block a user