-
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
Conversation
requisitos de aceiteCriar ponto de acesso que permite a exclusão definitiva de uma tarefa.
|
try to merge
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.
requisitos de aceite
Criar ponto de acesso que permite a exclusão definitiva de uma tarefa.
- Usuário deve estar autenticado
- A tarefa deve existir na base de dados
- A tarefa deve ser do usuário que fez o pedido de exclusão
- Uma mensagem avisando que a tarefa foi excluída definitivamente deve ser retornada.\
- Mensagem: "Atividade excluída com sucesso"
…kId, parentId, and childrenId
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.
🔍
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 comment
The 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.
async validateParent(parentId: string) { | ||
return await this.prisma.parentProfile.findUnique({ | ||
return this.prisma.parentProfile.findFirst({ | ||
where: { | ||
id: parentId, | ||
}, | ||
}); | ||
} |
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.
adiciona endpoint de deletar task