Jelajahi Sumber

remove inappropriate error handling in service

Futa Arai 2 tahun lalu
induk
melakukan
e0dde64a4c

+ 1 - 4
apps/app/public/static/locales/en_US/admin.json

@@ -1081,10 +1081,7 @@
       "name_mapper_detail": "Attribute to map as group name",
       "updated_group_sync_settings": "Updated LDAP group sync settings",
       "password": "Password",
-      "password_detail": "Login password is necessary because Bind type is set to User Bind",
-      "circular_reference": "Sync failed because there is a possible circular reference in your LDAP group tree structure",
-      "group_search_failed": "LDAP group search failed. Please check your LDAP security settings and group sync settings.",
-      "user_search_failed": "LDAP user search failed. Please check your LDAP security settings and group sync settings."
+      "password_detail": "Login password is necessary because Bind type is set to User Bind"
     },
     "keycloak": {
       "group_sync_settings": "Keycloak Group Sync Settings",

+ 1 - 4
apps/app/public/static/locales/ja_JP/admin.json

@@ -1090,10 +1090,7 @@
       "name_mapper_detail": "グループの「名前」として読み込む属性",
       "updated_group_sync_settings": "LDAP グループ同期設定を更新しました",
       "password": "パスワード",
-      "password_detail": "認証設定がユーザ Bind のため、ログイン時のパスワードの入力が必要となります",
-      "circular_reference": "LDAP グループの木構造に循環参照が行われている可能性があるため、同期に失敗しました",
-      "group_search_failed": "LDAP グループ検索に失敗しました。LDAP セキュリティ設定、グループ同期設定が正しいことを確認してください。",
-      "user_search_failed": "LDAP ユーザ検索に失敗しました。LDAP セキュリティ設定、グループ同期設定が正しいことを確認してください。"
+      "password_detail": "認証設定がユーザ Bind のため、ログイン時のパスワードの入力が必要となります"
     },
     "keycloak": {
       "group_sync_settings": "Keycloak グループ同期設定",

+ 1 - 4
apps/app/public/static/locales/zh_CN/admin.json

@@ -1089,10 +1089,7 @@
       "name_mapper_detail": "Attribute to map as group name",
       "updated_group_sync_settings": "Updated LDAP group sync settings",
       "password": "Password",
-      "password_detail": "Login password is necessary because Bind type is set to User Bind",
-      "circular_reference": "Sync failed because there is a possible circular reference in your LDAP group tree structure",
-      "group_search_failed": "LDAP group search failed. Please check your LDAP security settings and group sync settings.",
-      "user_search_failed": "LDAP user search failed. Please check your LDAP security settings and group sync settings."
+      "password_detail": "Login password is necessary because Bind type is set to User Bind"
     },
     "keycloak": {
       "group_sync_settings": "Keycloak Group Sync Settings",

+ 4 - 21
apps/app/src/features/external-user-group/server/service/ldap-user-group-sync.ts

@@ -1,7 +1,6 @@
 import { configManager } from '~/server/service/config-manager';
 import LdapService, { SearchResultEntry } from '~/server/service/ldap';
 import PassportService from '~/server/service/passport';
-import loggerFactory from '~/utils/logger';
 import { batchProcessPromiseAll } from '~/utils/promise';
 
 import {
@@ -10,8 +9,6 @@ import {
 
 import ExternalUserGroupSyncService from './external-user-group-sync';
 
-const logger = loggerFactory('growi:service:ldap-user-group-sync-service');
-
 // When d = max depth of group trees
 // Max space complexity of generateExternalUserGroupTrees will be:
 // O(TREES_BATCH_SIZE * d * USERS_BATCH_SIZE)
@@ -41,15 +38,8 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService<SyncParamsTy
     const groupDescriptionAttribute: string = configManager.getConfig('crowi', 'external-user-group:ldap:groupDescriptionAttribute');
     const groupBase: string = this.ldapService.getGroupSearchBase();
 
-    let groupEntries: SearchResultEntry[];
-    try {
-      await this.ldapService.bind(options?.userBindUsername, options?.userBindPassword);
-      groupEntries = await this.ldapService.searchGroupDir();
-    }
-    catch (e) {
-      logger.error(e.message);
-      throw Error('external_user_group.ldap.group_search_failed');
-    }
+    await this.ldapService.bind(options?.userBindUsername, options?.userBindPassword);
+    const groupEntries = await this.ldapService.searchGroupDir();
 
     const getChildGroupDnsFromGroupEntry = (groupEntry: SearchResultEntry) => {
       // groupChildGroupAttribute and groupMembershipAttribute may be the same,
@@ -67,7 +57,7 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService<SyncParamsTy
       if (name == null) return null;
 
       if (converted.includes(entry.objectName)) {
-        throw Error('external_user_group.ldap.circular_reference');
+        throw Error('Circular reference inside LDAP group tree');
       }
       converted.push(entry.objectName);
 
@@ -128,14 +118,7 @@ class LdapUserGroupSyncService extends ExternalUserGroupSyncService<SyncParamsTy
       }
     };
 
-    let userEntries: SearchResultEntry[] | undefined;
-    try {
-      userEntries = await getUserEntries();
-    }
-    catch (e) {
-      logger.error(e.message);
-      throw Error('external_user_group.ldap.user_search_failed');
-    }
+    const userEntries = await getUserEntries();
 
     if (userEntries != null && userEntries.length > 0) {
       const userEntry = userEntries[0];