Skip to content
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

Allow unauthenticated users to view group details #3461

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lego/apps/users/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def has_perm(

class AbakusGroupPermissionHandler(PermissionHandler):
permission_map = {LIST: [], VIEW: []} # type: ignore
authentication_map = {LIST: False, VIEW: False}

force_object_permission_check = True
default_keyword_permission = "/sudo/admin/groups/{perm}/"
Expand All @@ -51,6 +52,7 @@ def has_perm(
):
if perm == "delete":
return False

has_perm = super().has_perm(
user, perm, obj, queryset, check_keyword_permissions, **kwargs
)
Expand Down
4 changes: 2 additions & 2 deletions lego/apps/users/tests/test_abakusgroup_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def successful_list(self, user):

def test_without_auth(self):
response = self.client.get(_get_list_url())
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_with_auth(self):
self.successful_list(self.user)
Expand Down Expand Up @@ -94,7 +94,7 @@ def successful_retrieve(self, user, pk):

def test_without_auth(self):
response = self.client.get(_get_detail_url(1))
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_with_permission(self):
self.successful_retrieve(self.with_permission, self.test_group.pk)
Expand Down