Skip to content

Commit 8833228

Browse files
committed
Added guards against instances of queryset filtering using an object without primary key.
- Legacy-Id: 12642
1 parent 74753b6 commit 8833228

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ietf/dbtemplate/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def template_list(request, acronym):
1313
group = get_object_or_404(Group, acronym=acronym)
1414
chairs = group.role_set.filter(name__slug='chair')
15-
if not has_role(request.user, "Secretariat") and not chairs.filter(person__user=request.user).count():
15+
if not has_role(request.user, "Secretariat") and not (request.user.id and chairs.filter(person__user=request.user).count()):
1616
return HttpResponseForbidden("You are not authorized to access this view")
1717

1818
template_list = DBTemplate.objects.filter(group=group)
@@ -51,7 +51,7 @@ def template_show(request, acronym, template_id, base_template='dbtemplate/templ
5151
chairs = group.role_set.filter(name__slug='chair')
5252
extra_context = extra_context or {}
5353

54-
if not has_role(request.user, "Secretariat") and not chairs.filter(person__user=request.user).count():
54+
if not has_role(request.user, "Secretariat") and not (request.user.id and chairs.filter(person__user=request.user).count()):
5555
return HttpResponseForbidden("You are not authorized to access this view")
5656

5757
template = get_object_or_404(DBTemplate, id=template_id, group=group)

0 commit comments

Comments
 (0)