mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
fix: Fix broken user check when anonymous
This commit is contained in:
@@ -30,4 +30,8 @@ class UserIsLinkedPersonMixin(UserPassesTestMixin):
|
|||||||
return getattr(self.get_object(), self.related_person_field)
|
return getattr(self.get_object(), self.related_person_field)
|
||||||
|
|
||||||
def test_func(self) -> bool:
|
def test_func(self) -> bool:
|
||||||
return self.request.user.is_staff or self.get_test_person() == self.request.user.person
|
"""
|
||||||
|
Require that user is either staff or is the linked person.
|
||||||
|
"""
|
||||||
|
user = self.request.user
|
||||||
|
return user.is_authenticated and (user.is_staff or self.get_test_person() == user.person)
|
||||||
|
|||||||
Reference in New Issue
Block a user