prevent test account from being deleted

This commit is contained in:
2024-11-23 12:19:10 +01:00
parent 26d2f111a3
commit 1a776b57ac

View File

@@ -1,3 +1,4 @@
import { BadRequestException } from '@nestjs/common'
import { CommandHandler, ICommandHandler } from '@nestjs/cqrs'
import { UsersRepository } from '../../users/infrastructure/users.repository'
@@ -13,6 +14,10 @@ export class DeleteCurrentUserAccountHandler
constructor(private readonly usersRepository: UsersRepository) {}
async execute(command: DeleteCurrentAccountCommand): Promise<boolean> {
if (command.userId === '16163541-acf6-4ad4-ab16-1546309979a5') {
throw new BadRequestException('Test account cannot be deleted')
}
return await this.usersRepository.deleteUserById(command.userId)
}
}