mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-08-21 16:47:22 +02:00
Prevent errors when a not authenticated user tries to see a user detail page
This commit is contained in:
@@ -158,6 +158,8 @@ class UserDetailView(LoginRequiredMixin, DetailView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
if not user.is_authenticated:
|
||||
return self.handle_no_permission()
|
||||
# Only an admin or the concerned user can see the information
|
||||
if not user.registration.is_admin and user.pk != kwargs["pk"]:
|
||||
raise PermissionDenied
|
||||
|
Reference in New Issue
Block a user