fix: prevent admin from login to console of user
This commit is contained in:
@@ -91,6 +91,8 @@ export class AuthService {
|
||||
|
||||
const user = await this.checkUserLoginCredentialWithEmail(email, password);
|
||||
|
||||
if (!user.roles.some((role) => !role.isAdmin)) throw new BadRequestException(AuthMessage.ADMIN_CAN_NOT_LOGIN);
|
||||
|
||||
const tokens = this.generateAccessAndRefreshToken(user);
|
||||
|
||||
await this.notificationService.createLoginNotification(user.id);
|
||||
@@ -169,6 +171,9 @@ export class AuthService {
|
||||
|
||||
const user = await this.checkUserLoginCredentialWithPhone(phone, code);
|
||||
|
||||
if (!user.roles.some((role) => !role.isAdmin)) throw new BadRequestException(AuthMessage.ADMIN_CAN_NOT_LOGIN);
|
||||
// if (user.roles.some((role) => role.isAdmin)) throw new BadRequestException(AuthMessage.ADMIN_CAN_NOT_LOGIN);
|
||||
|
||||
const tokens = this.generateAccessAndRefreshToken(user);
|
||||
|
||||
await this.notificationService.createLoginNotification(user.id);
|
||||
|
||||
Reference in New Issue
Block a user