1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 07:02:22 +00:00

Non-admin users can't promote themselves to admin users

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2023-05-20 11:35:37 +02:00
parent 310ac70a74
commit 777ae059f9
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85

View File

@ -275,6 +275,8 @@ class UserUpdateView(UserMixin, UpdateView):
if not self.request.user.registration.is_admin:
if "team" in context["registration_form"].fields:
del context["registration_form"].fields["team"]
if "admin" in context["registration_form"].fields:
del context["registration_form"].fields["admin"]
del context["registration_form"].fields["email_confirmed"]
return context
@ -286,6 +288,8 @@ class UserUpdateView(UserMixin, UpdateView):
if not self.request.user.registration.is_admin:
if "team" in registration_form.fields:
del registration_form.fields["team"]
if "admin" in registration_form.fields:
del registration_form.fields["admin"]
del registration_form.fields["email_confirmed"]
if not registration_form.is_valid():