mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-16 20:59:26 +00:00
prevent test account from being deleted
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user