From b29b4d304df95718b37eee65c4f6f4912080f652 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Wed, 18 Mar 2026 11:07:51 +0100 Subject: [PATCH] fix(user) : clear allowedProjects when removing ROLE_CLIENT Prevents sending /api/projects/undefined when saving a user after removing client role. Also auto-clears client and projects when ROLE_CLIENT checkbox is unchecked. Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/components/user/UserDrawer.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/components/user/UserDrawer.vue b/frontend/components/user/UserDrawer.vue index 57fc736..28221e5 100644 --- a/frontend/components/user/UserDrawer.vue +++ b/frontend/components/user/UserDrawer.vue @@ -148,6 +148,13 @@ function onClientChange(value: number | null) { } } +watch(() => form.roles, (roles) => { + if (!roles.includes('ROLE_CLIENT')) { + form.clientId = null + form.allowedProjectIds = [] + } +}) + watch(() => props.modelValue, async (open) => { if (open) { if (props.item) { @@ -189,7 +196,9 @@ async function handleSubmit() { username: form.username.trim(), roles: form.roles, client: form.clientId !== null ? `/api/clients/${form.clientId}` : null, - allowedProjects: form.allowedProjectIds.map((id) => `/api/projects/${id}`), + allowedProjects: form.clientId !== null + ? form.allowedProjectIds.map((id) => `/api/projects/${id}`) + : [], } if (form.password) { payload.plainPassword = form.password