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

Closed
opened 2021-04-24 12:45:57 +02:00 by leuckeju · 9 comments
Member

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: ```
Author
Member

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)
Owner

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.
Owner

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/
Owner

created merge request !578 to address this issue

created merge request !578 to address this issue
Owner

mentioned in merge request !578

mentioned in merge request !578
Owner

mentioned in merge request AlekSIS-Core!998

mentioned in merge request AlekSIS-Core!998
Owner

mentioned in commit be2c32f270

mentioned in commit be2c32f270f06c115a42ddbc170cf0cb22299f72
nik closed this issue 2021-05-16 16:59:31 +02:00
Owner

unassigned @fph

unassigned @fph
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
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.