fix: prevent admin from login to console of user
This commit is contained in:
@@ -53,7 +53,8 @@ export const enum AuthMessage {
|
||||
TOO_MANY_REQUESTS = "تعداد درخواست های شما بیش از حد مجاز است",
|
||||
NOT_ADMIN = "شما دسترسی به بخش ادمین ندارید",
|
||||
PHONE_SHOULD_BE_11_DIGIT = "شماره تلفن باید ۱۱ رقم باشد",
|
||||
TIMESTAMP_NOT_EMPTY = "TIMESTAMP_NOT_EMPTY",
|
||||
TIMESTAMP_NOT_EMPTY = "زمان نمیتواند خالی باشد",
|
||||
ADMIN_CAN_NOT_LOGIN = "ادمین نمیتواند وارد شود",
|
||||
}
|
||||
|
||||
export const enum UserMessage {
|
||||
|
||||
@@ -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