login operador final

This commit is contained in:
Lemuel Marquez
2021-05-20 16:00:39 -05:00
parent 18df5afb80
commit afde901509
+3 -1
View File
@@ -15,13 +15,15 @@ const login = async (body) => {
);
return Operador.findOne({
where: { operador },
where: { operador, activo: true },
include: [{ model: TipoUsuario }],
}).then((res) => {
if (!res) throw new Error('No existe este operador.');
if (!res.activo) throw new Error('Este operador no esta activo.');
if (comparar(password, res.password)) {
delete res.dataValues.password;
delete res.dataValues.activo;
delete res.dataValues.idTipoUsuario;
return {
Operador: res,
token: crearTokenOperador({