Permission checking decorators raise internal server error if the user is anonymous #157

Closed
opened 2021-04-24 12:45:57 +02:00 by ZugBahnHof · 9 comments
ZugBahnHof commented 2021-04-24 12:45:57 +02:00 (Migrated from edugit.org)

Some views raise an HTTP 500 error if the user is currently not signed in. Example:

@permission_required(
    "alsijil.view_person_overview",
    fn=objectgetter_optional(
        Person.objects.prefetch_related("member_of__owners"), "request.user.person", True
    ),
)
def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResponse:
Some views raise an HTTP 500 error if the user is currently not signed in. Example: ```python @permission_required( "alsijil.view_person_overview", fn=objectgetter_optional( Person.objects.prefetch_related("member_of__owners"), "request.user.person", True ), ) def overview_person(request: HttpRequest, id_: Optional[int] = None) -> HttpResponse: ```
ZugBahnHof commented 2021-04-24 12:46:40 +02:00 (Migrated from edugit.org)

The Code is from views.py Line 728

The Code is from [views.py Line 728](https://edugit.org/AlekSIS/official/AlekSIS-App-Alsijil/-/blob/master/aleksis/apps/alsijil/views.py#L728)
nik commented 2021-04-24 13:36:34 +02:00 (Migrated from edugit.org)

When touching the views to fix it, please take the time to convert them to class-based views while at it.

When touching the views to fix it, please take the time to convert them to class-based views while at it.
nik commented 2021-05-16 12:01:18 +02:00 (Migrated from edugit.org)

assigned to @fph

assigned to @fph
fph commented 2021-05-16 13:26:26 +02:00 (Migrated from edugit.org)

The error occurs with the following URLs:

  • /preferences/person/
  • /person
  • /app/alsijil/me/
  • /app/alsijil/group_roles/assignments/assign/
The error occurs with the following URLs: - [x] /preferences/person/ - [x] /person - [x] /app/alsijil/me/ - [x] /app/alsijil/group_roles/assignments/assign/
hansegucker commented 2021-05-16 16:02:12 +02:00 (Migrated from edugit.org)

created merge request !578 to address this issue

created merge request !578 to address this issue
hansegucker commented 2021-05-16 16:02:13 +02:00 (Migrated from edugit.org)

mentioned in merge request !578

mentioned in merge request !578
hansegucker commented 2021-05-16 16:56:38 +02:00 (Migrated from edugit.org)

mentioned in merge request AlekSIS-Core!998

mentioned in merge request AlekSIS-Core!998
nik commented 2021-05-16 16:59:31 +02:00 (Migrated from edugit.org)

mentioned in commit be2c32f270

mentioned in commit be2c32f270f06c115a42ddbc170cf0cb22299f72
nik (Migrated from edugit.org) closed this issue 2021-05-16 16:59:31 +02:00
nik commented 2025-02-24 12:19:15 +01:00 (Migrated from edugit.org)

unassigned @fph

unassigned @fph
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aleksis/AlekSIS-App-Alsijil#157
No description provided.