From 1cb01c8fd4fb9c1419075e4555bf14d7be9c1916 Mon Sep 17 00:00:00 2001 From: Norman Niati Date: Mon, 18 May 2026 14:42:16 +0200 Subject: [PATCH] fix(plugin-id): replace hardcoded entity probes with list probes for demo-mode detection The previous probes ('user/admin', 'company/Ligoj' and 'group/Engineering') checked for specific entities that don't exist in real LDAP backends, causing the "Mode demo" banner to appear incorrectly on /new pages whenever a real IAM provider (plugin-iam-node + plugin-id-ldap) is configured. Switch to list endpoints with rows=1 which return 200 with an empty data array when nothing matches, and only set code on real API failures. Per Fabrice's review in 18 mai 13:30 meeting. --- ui/src/views/CompanyEditView.vue | 6 +++++- ui/src/views/GroupEditView.vue | 6 +++++- ui/src/views/UserEditView.vue | 7 +++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/src/views/CompanyEditView.vue b/ui/src/views/CompanyEditView.vue index 02138e2..d31a1f3 100644 --- a/ui/src/views/CompanyEditView.vue +++ b/ui/src/views/CompanyEditView.vue @@ -223,7 +223,11 @@ onMounted(async () => { { title: t('company.title'), to: '/id/company' }, { title: t('company.new') }, ]) - const check = await api.get('rest/service/id/company/Ligoj') + // Check if API is available. Use a list probe (rows=1) so the check doesn't + // depend on a specific hardcoded entity that may or may not exist in the + // real LDAP backend. The list endpoint returns 200 with an empty array when + // nothing matches, and `code` is only set on real API errors. + const check = await api.get('rest/service/id/company?rows=1&page=1') if (!check || check.code) { demoMode.value = true errorStore.clear() diff --git a/ui/src/views/GroupEditView.vue b/ui/src/views/GroupEditView.vue index a660fcf..d728e2a 100644 --- a/ui/src/views/GroupEditView.vue +++ b/ui/src/views/GroupEditView.vue @@ -168,7 +168,11 @@ onMounted(async () => { { title: t('group.title'), to: '/id/group' }, { title: t('group.new') }, ]) - const check = await api.get('rest/service/id/group/Engineering') + // Check if API is available. Use a list probe (rows=1) so the check doesn't + // depend on a specific hardcoded entity that may or may not exist in the + // real LDAP backend. The list endpoint returns 200 with an empty array when + // nothing matches, and `code` is only set on real API errors. + const check = await api.get('rest/service/id/group?rows=1&page=1') if (!check || check.code) { demoMode.value = true errorStore.clear() diff --git a/ui/src/views/UserEditView.vue b/ui/src/views/UserEditView.vue index 48424ec..5966d68 100644 --- a/ui/src/views/UserEditView.vue +++ b/ui/src/views/UserEditView.vue @@ -400,8 +400,11 @@ onMounted(async () => { { title: t('user.title'), to: '/id/user' }, { title: t('user.new') }, ]) - // Check if API is available - const check = await api.get('rest/service/id/user/admin') + // Check if API is available. Use a list probe (rows=1) so the check doesn't + // depend on a specific hardcoded entity that may or may not exist in the + // real LDAP backend. The list endpoint returns 200 with an empty array when + // nothing matches, and `code` is only set on real API errors. + const check = await api.get('rest/service/id/user?rows=1&page=1') if (!check || check.code) { demoMode.value = true errorStore.clear()