Skip to content
Snippets Groups Projects
Commit f54d6580 authored by L4168's avatar L4168
Browse files

updated login service exceptions

parent 7ed2d801
No related branches found
No related tags found
3 merge requests!59Development to master,!31Development,!23Faction tasks + Piirto
...@@ -30,8 +30,11 @@ export class UserService { ...@@ -30,8 +30,11 @@ export class UserService {
async login(data: UserDTO) { async login(data: UserDTO) {
const { name, password } = data; const { name, password } = data;
const user = await this.userRepository.findOne({ where: { name } }); const user = await this.userRepository.findOne({ where: { name } });
if (!user || !(await user.comparePassword(password))) { if (!user) {
throw new HttpException('invalid password', HttpStatus.BAD_REQUEST); throw new HttpException('User does not exist', HttpStatus.BAD_REQUEST);
}
if (!(await user.comparePassword(password))) {
throw new HttpException('Invalid password', HttpStatus.BAD_REQUEST);
} }
return user.tokenObject(); return user.tokenObject();
} }
......
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