fix: prevent admin from login to console of user

This commit is contained in:
mahyargdz
2025-02-19 15:09:04 +03:30
parent 95e22e0886
commit 10825e5988
2 changed files with 7 additions and 1 deletions
@@ -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);