Skip to content

Commit 51b6809

Browse files
committed
Fixed a place where a logged-in user without associcated Person would cause a 500 instead of 403.
- Legacy-Id: 11474
1 parent 834bf08 commit 51b6809

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

ietf/secr/announcement/views.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,27 @@ def check_access(user):
1818
This function takes a Django User object and returns true if the user has access to
1919
the Announcement app.
2020
'''
21-
person = user.person
22-
groups_with_access = ("iab", "isoc", "isocbot", "rsoc", "ietf", "iaoc", "rse", "mentor","ietf-trust")
23-
if Role.objects.filter(person=person,
24-
group__acronym__in=groups_with_access,
25-
name="chair") or has_role(user, ["Secretariat","IAD"]):
26-
return True
27-
if Role.objects.filter(name="chair",
28-
group__acronym__startswith="nomcom",
29-
group__state="active",
30-
group__type="nomcom",
31-
person=person):
32-
return True
33-
if Role.objects.filter(person=person,
34-
group__acronym='iab',
35-
name='execdir'):
36-
return True
37-
if Role.objects.filter(person=person,
38-
group__acronym='isoc',
39-
name='ceo'):
40-
return True
21+
if hasattr(user, "person"):
22+
person = user.person
23+
groups_with_access = ("iab", "isoc", "isocbot", "rsoc", "ietf", "iaoc", "rse", "mentor","ietf-trust")
24+
if Role.objects.filter(person=person,
25+
group__acronym__in=groups_with_access,
26+
name="chair") or has_role(user, ["Secretariat","IAD"]):
27+
return True
28+
if Role.objects.filter(name="chair",
29+
group__acronym__startswith="nomcom",
30+
group__state="active",
31+
group__type="nomcom",
32+
person=person):
33+
return True
34+
if Role.objects.filter(person=person,
35+
group__acronym='iab',
36+
name='execdir'):
37+
return True
38+
if Role.objects.filter(person=person,
39+
group__acronym='isoc',
40+
name='ceo'):
41+
return True
4142

4243
return False
4344

0 commit comments

Comments
 (0)