Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Somente exibir campo de Contato quando logado(staff ou user) #77
Somente exibir campo de Contato quando logado(staff ou user) #77
Changes from 3 commits
9f5fabc
13d65ba
8db01be
ecdf8f4
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
esses dois ifs aqui ficaram redundantes, não?
porque se não tiver sessionId nem userId, a query abaixo já vai retornar false de qualquer jeito
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.
É só uma guard clause pra se não for informada nem gastar uma query com dado inválido. Posso remover se for o caso...
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 eu acho que não precisa do
ApplyUser
, pode usar direto@UseGuards(UserGuard)
e aí ele vai aprovar todo mundo que tenha, no mínimo, a permissão de User, visto que é uma hierarquia de permissõesThere 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.
O problema que usar o
![image](https://private-user-images.githubusercontent.com/22968607/329888584-6884a5e5-efb1-47d5-a79e-cede632f8ef4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiO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lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDIxNDMwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJlZTllMzA1M2RlMjI1Yzc1YjgwOTlmZmZjMzFhMzI3MjFjNTViZWM1N2Q5Yzg5MGNjODViZDU2MzQwMzY2YTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.rbt2y6VruG3BAiaeUGwWiiP6RQSUa6F-ZaPiXVFAYWs)
@UseGuards(UserGuard)
ele vai aplicar a restrição pra rota toda em vez de apenas um atributo(o de telefone). Então usuários não logados não vão conseguir ver os detalhes do abrigo quebrando essa página.As screens com o projeto rodando essa brach:
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.
aaah sim, te entendi. faz sentido.
pergunta: o nest.js não deveria ter um "ApplyUser" nativo não?
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.
não sei/consegui achar, se souber como eu altero já também
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 lógica aqui está correta.
porém, não acho que a camada de
service
precise receber o contexto do usuário que está logado.por isso, essa lógica deveria ficar na camada de
controller
e aqui o métodoshow
poderia receber um boolean por parametro chamadoshouldShowContact
que por padrão é false.assim a funcionalidade segue a mesma, mas mantemos a integridade da responsabilidade da
service
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.
Sim, é uma boa, vou alterar
Já aproveitando o gancho: será que não seria interessante já seguir o padrão
repository
também pra puxar essas partes do banco e deixar a camada deservice
somente com as regras de negócio? até facilitaria o teste de services sem precisar mockar...