Skip to content

Commit

Permalink
fix(AUTH): agrega control para usuarios one login al generar un nuevo…
Browse files Browse the repository at this point in the history
… usuario
  • Loading branch information
silviroa committed Jun 19, 2024
1 parent f159ad5 commit 1dbb87f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ export async function createUser(data) {
user.nombre = data.nombre;
user.apellido = data.apellido;
user.email = data.email;
user.authMethod = 'password';
user.tipo = 'temporal';
user.authMethod = data.authMethod;
user.tipo = data.tipo;

const organizacion = await Organizacion.findOne({ matriculacion: true });
const permisos = getPermisosByType(data.tipoPermisos);
Expand Down
18 changes: 17 additions & 1 deletion modules/gestor-usuarios/usuarios.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,24 @@ UsuariosRouter.post('/usuarios/create', Auth.authenticate(), async (req, res, ne
if (existsUser) {
return next('Ya posee un usuario en Andes');
}
req.body.authMethod = 'password';
req.body.tipo = 'temporal';
let userOneLogin;
const documento = req.body.documento;
try {
userOneLogin = await getUserInfo(documento);
} catch {
userOneLogin = null;
}
if (userOneLogin) {
req.body.authMethod = '';
req.body.tipo = '';
}
const user = await createUser(req.body);
await setValidationTokenAndNotify(req.body.documento);
if (req.body.authMethod === 'oneLogin') {
await setValidationTokenAndNotify(documento);
}

return res.json(user);

} catch (err) {
Expand Down

0 comments on commit 1dbb87f

Please sign in to comment.