diff --git a/src/tasks/tasks.controller.ts b/src/tasks/tasks.controller.ts index 4d1811c..fff4bd1 100644 --- a/src/tasks/tasks.controller.ts +++ b/src/tasks/tasks.controller.ts @@ -45,8 +45,8 @@ export class TasksController { } @Delete('/:id') - deleteTask(@Param('id') id: string): Promise { - return this.tasksService.deleteTask(id); + deleteTask(@Param('id') id: string, @GetUser() user: User): Promise { + return this.tasksService.deleteTask(id, user); } @Patch('/:id/status') diff --git a/src/tasks/tasks.service.ts b/src/tasks/tasks.service.ts index 855a065..3db053c 100644 --- a/src/tasks/tasks.service.ts +++ b/src/tasks/tasks.service.ts @@ -19,9 +19,7 @@ export class TasksService { } async getTaskById(id: string, user: User): Promise { - const foundTask = await this.tasksRepository.findOne({ - where: { id, user }, - }); + const foundTask = await this.tasksRepository.findOne({ id, user }); if (!foundTask) { throw new NotFoundException(`Task with ID ${id} is not found.`); @@ -33,8 +31,8 @@ export class TasksService { return this.tasksRepository.createTask(createTaskDto, user); } - async deleteTask(id: string): Promise { - const result = await this.tasksRepository.delete(id); + async deleteTask(id: string, user: User): Promise { + const result = await this.tasksRepository.delete({ id, user }); if (result.affected === 0) { throw new NotFoundException(`Task with ID "${id}" is not found.`); }