Skip to content
Snippets Groups Projects
Commit 3238fa6a authored by Ignacio Otero's avatar Ignacio Otero
Browse files

Arreglos de mensajes de error

parent d08ec9ba
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@ const create = async (req: Request, res: Response): Promise<Response> => {
return res.status(200).send(user);
} catch (error) {
const e = error as Error;
console.log(e.message);
return res.status(400).json({ error: e.message });
}
};
......@@ -135,6 +136,7 @@ const login = async (req: Request, res: Response): Promise<Response> => {
});
} catch (error) {
const e = error as Error;
console.log(e.message);
return res.status(400).json({ error: e.message });
}
};
......
......@@ -404,20 +404,19 @@ const login = async (userDTO: UserLoginDTO): Promise<User> => User.findOne({
],
where: {
email: userDTO.email,
status: status.approved,
active: true,
},
}).then((user: User) => {
if (!user) {
throw new Error('user not found');
} else if (user.get('status') === status.pending || user.get('active') === false) {
throw new Error('user not accepted');
} else if (user && bcrypt.compareSync(userDTO.password, String(user.get('password')))) {
return user;
} else {
throw new Error('auth failed');
}
}).catch((error: Error) => {
console.log(error);
throw new Error('find user error');
throw error;
});
const listUsersById = async (ids: number[]): Promise<User[]> => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment