-
Notifications
You must be signed in to change notification settings - Fork 1
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
✨(maildomain_access) add API endpoint to search users #561
Conversation
75b44d1
to
23eb00b
Compare
68ae501
to
10e7537
Compare
Dans les get_abilities il y a manage_access qui me permettrait de limiter l'accès à ce endpoint. |
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.
Je pense que tu as raison, ça serait bien de limiter aux utilisateurs de la même organisation :)
@action(detail=False, url_path="users", methods=["get"]) | ||
def get_available_users(self, request, domain_slug): | ||
"""API endpoint to search user to give them new access. | ||
More filters and permission will be added soon. |
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.
This is a bit of a nitpick, but I feel that docstrings should be focused on the current state of the code, it's not really their job to say what is "coming soon".
core_models.User.objects.all() | ||
.order_by("-created_at") | ||
# exclude inactive contacts | ||
.filter(is_active=True) |
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.
This filter is not exercised by the test, I think ?
More filters and permission will be added soon. | ||
""" | ||
queryset = ( | ||
core_models.User.objects.all() |
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.
A note here that this raises a similar problem to issue #35 - if I'm authenticated it lets me see (effectively) all users.
From an API design perspective it's also a bit weird because this is an endpoint where we specify a domain, in order to see all users who do not have access to that domain (L199). It makes L79 quite misleading.
It would perhaps be more coherent to have an "exclude_by_domain_access" parameter on the /users/ endpoint ?
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.
(On the /users/ endpoint we already have a parameter - undocumented - to exclude users already on a team… I think for similar reasons; for consistency and for better clarity they should be named something like exclude_xxx)
3ffe70c
to
c8b5673
Compare
74a54ae
to
dac3cd3
Compare
abilities = domain.get_abilities(request.user) | ||
if not abilities["manage_accesses"]: | ||
raise exceptions.PermissionDenied() |
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.
Should you consider adding a get_available_users
to the abilities?
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.
User needs to list available users to manage access, so adding get_available_users
to abilities would be a duplicate.
if role == enums.MailDomainRoleChoices.VIEWER: | ||
assert response.status_code == status.HTTP_403_FORBIDDEN | ||
else: |
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.
I'm sorry, but this is a bad pattern in tests, there should not be logic like that here :/
if role == enums.MailDomainRoleChoices.VIEWER: | ||
assert response.status_code == status.HTTP_403_FORBIDDEN | ||
else: |
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.
Same here, we don't want logic in tests
dac3cd3
to
f2900ef
Compare
Add new API endpoint to search for new users to whom we can assign new roles.
f2900ef
to
5d84e22
Compare
closes #508