From 4c503dc513dddeab192b09125ef0af42ea75cefc Mon Sep 17 00:00:00 2001 From: marwanehcine Date: Thu, 9 Nov 2023 01:46:18 +0100 Subject: [PATCH 1/2] fix org issue for oauth2 users --- .../gateway/accounts/admin/ldap/LdapAccountsManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java b/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java index 50a33c77..6abfc7d9 100644 --- a/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java +++ b/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java @@ -95,7 +95,9 @@ protected void createInternal(GeorchestraUser mapped) { throw new IllegalStateException(accountError); } - ensureOrgExists(newAccount); + if (newAccount.getOAuth2ProviderId() == null) { + ensureOrgExists(newAccount); + } ensureRolesExist(mapped, newAccount); } From 38a8829b0a45bb00bad178b01bd16b0b74095c90 Mon Sep 17 00:00:00 2001 From: Emmanuel Durin Date: Thu, 9 Nov 2023 10:11:29 +0100 Subject: [PATCH 2/2] WIP --- .../gateway/accounts/admin/ldap/LdapAccountsManager.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java b/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java index 6abfc7d9..bccff0a2 100644 --- a/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java +++ b/gateway/src/main/java/org/georchestra/gateway/accounts/admin/ldap/LdapAccountsManager.java @@ -95,9 +95,7 @@ protected void createInternal(GeorchestraUser mapped) { throw new IllegalStateException(accountError); } - if (newAccount.getOAuth2ProviderId() == null) { - ensureOrgExists(newAccount); - } + ensureOrgExists(newAccount); ensureRolesExist(mapped, newAccount); } @@ -155,7 +153,7 @@ private Account mapToAccountBrief(@NonNull GeorchestraUser preAuth) { private void ensureOrgExists(@NonNull Account newAccount) { String orgId = newAccount.getOrg(); - if (null == orgId) + if ((null == orgId) || orgId.isEmpty()) return; try { // account created, add org Org org;