anhledger12 commited on
Commit
5ebbd78
·
unverified ·
2 Parent(s): 28ab9e0 514bc54

Merge pull request #32 from PBL6-team-CATS/fix/no-user-log-in

Browse files
backend/src/modules/authentication/authentication.service.ts CHANGED
@@ -22,8 +22,10 @@ export class AuthenticationService {
22
  user = await this.usersService.findOneByField('email', username);
23
  else
24
  user = await this.usersService.findOneByField('phone_number', username);
 
 
25
  const compare = await bcrypt.compare(pass, user.hash_password)
26
- if (( !user || !compare )) {
27
  throw new UnauthorizedException();
28
  }
29
  const payload = { sub: user.id, username: user.full_name, roles: user.role};
 
22
  user = await this.usersService.findOneByField('email', username);
23
  else
24
  user = await this.usersService.findOneByField('phone_number', username);
25
+ if (!user)
26
+ throw new UnauthorizedException();
27
  const compare = await bcrypt.compare(pass, user.hash_password)
28
+ if (!compare) {
29
  throw new UnauthorizedException();
30
  }
31
  const payload = { sub: user.id, username: user.full_name, roles: user.role};