From 43e1c486f1dfbf2397246ab3353fca0bd251fdbd Mon Sep 17 00:00:00 2001
From: Antoine D <106921102+Suboyyy@users.noreply.github.com>
Date: Fri, 11 Oct 2024 19:34:34 +0200
Subject: [PATCH] security: disable possibility for non-admin users from
editing fields except "place" in user modal (#404)
---
src/components/dashboard/UserModal.tsx | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/src/components/dashboard/UserModal.tsx b/src/components/dashboard/UserModal.tsx
index c53af6b9..22de6503 100644
--- a/src/components/dashboard/UserModal.tsx
+++ b/src/components/dashboard/UserModal.tsx
@@ -275,26 +275,20 @@ const UserModal = ({
containerClassName={styles.userModal}>
<>
-
-
+
+
{(!searchUser || searchUser.type !== UserType.attendant) && (
<>
-
-
+
+
{!searchUser && (
-
+
)}
{searchUser && (
<>
@@ -426,7 +420,7 @@ const UserModal = ({
options={typeOptions}
value={type?.toString()}
onChange={(v) => setType(v as unknown as UserType)}
- disabled={searchUser.hasPaid}>
+ disabled={searchUser.hasPaid || !isAdmin}>
setAge(v as unknown as UserAge)}
disabled={
+ !isAdmin ||
searchUser.type === UserType.attendant ||
(searchUser.hasPaid && searchUser.age === UserAge.child && searchUser.attendant !== null)
}>
{searchUser.type !== UserType.attendant && (
<>
-
+
>
)}
>