-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/delete task #45
base: develop
Are you sure you want to change the base?
Feat/delete task #45
Changes from 5 commits
1ccf235
e2585ef
1cb5633
91b0c56
071c298
63f6e4d
d4a7aeb
bdca173
ca8ceae
1d31317
9f110bd
6ab8d2e
1ca16e8
055f443
d5471f4
0a3d422
7870d59
4a583d4
490d68a
7a7241e
ac9998f
c712921
af63231
35d3341
32b4a9b
55a2f7c
9e0d02d
bed88b6
6774b5a
5373258
98e27e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,14 +44,13 @@ export class TaskService { | |
} | ||
|
||
async deleteTask(input: iTaskRepositoryDeleteTaskInput) { | ||
const taskId = parseInt(input.id); | ||
const childrenId = parseInt(input.childrenId); | ||
const { taskId, childrenId, parentId } = input; | ||
|
||
const existingTask = await this.repository.findTaskByIdAndChildren( | ||
taskId, | ||
childrenId, | ||
); | ||
const parent = await this.repository.validateParent(input.parentId); | ||
const parent = await this.repository.validateParent(parentId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aqui apenas está sendo validado se a tarefa existe e se a conta existe, não valida se a conta é dona da tarefa, no caso, se ela tem permissão para excluir. Opção: Usar os tres parametros taskId, childrenId, parentId, para verificar se é um tarefa existente e pertence a essa pessoa. Outro ponto: Não precisa validar se o parentId é valido uma vez que ele já validado no módulo de autorização e seu valor é obtido da resposta desse módulo. OBS: Atualmente, outro usuário tem permissão de deletar tarefa que não é dele. Mas alterando a verificar já deve corrigir também. |
||
|
||
if (!existingTask) { | ||
throw new CustomHttpError('Tarefa não encontrada', 404); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essa verificação de conta já é realizada na autorização, certo? se tiver mais algum motivo pra usá-la, tudo bem.