1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-06-21 01:58:23 +02:00

Fix the permission to see a user page

This commit is contained in:
Yohann D'ANELLO
2021-01-23 11:02:26 +01:00
parent 0cd7ff512f
commit ea38c06631
3 changed files with 14 additions and 30 deletions

View File

@ -20,6 +20,14 @@ class VolunteerMixin(LoginRequiredMixin):
class UserMixin(LoginRequiredMixin):
def dispatch(self, request, *args, **kwargs):
user = request.user
if user.is_authenticated and not user.registration.is_admin and user.pk != kwargs["pk"]:
self.handle_no_permission()
return super().dispatch(request, *args, **kwargs)
class UserRegistrationMixin(LoginRequiredMixin):
def dispatch(self, request, *args, **kwargs):
user = request.user
if user.is_authenticated and not user.registration.is_admin and user.registration.pk != kwargs["pk"]: