Kaynağa Gözat

refs 114885: get actual val for activeExternalAccountTypes

Futa Arai 3 yıl önce
ebeveyn
işleme
d1ac6f6fcc

+ 1 - 3
packages/app/src/components/Questionnaire/QuestionnaireModal.tsx

@@ -1,9 +1,7 @@
 import { useCallback } from 'react';
 import { useCallback } from 'react';
 
 
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
-import {
-  Modal, ModalHeader, ModalBody, ModalFooter,
-} from 'reactstrap';
+import { Modal, ModalBody } from 'reactstrap';
 
 
 import { apiv3Put } from '~/client/util/apiv3-client';
 import { apiv3Put } from '~/client/util/apiv3-client';
 import { toastSuccess, toastError } from '~/client/util/toastr';
 import { toastSuccess, toastError } from '~/client/util/toastr';

+ 9 - 1
packages/app/src/interfaces/questionnaire/growi-info.ts

@@ -23,11 +23,19 @@ const GrowiDeploymentType = {
   node: 'node',
   node: 'node',
   others: 'others',
   others: 'others',
 } as const;
 } as const;
+export const GrowiExternalAuthProviderType = {
+  ldap: 'ldap',
+  saml: 'saml',
+  oicd: 'oidc',
+  google: 'google',
+  github: 'github',
+} as const;
 
 
 export type GrowiServiceType = typeof GrowiServiceType[keyof typeof GrowiServiceType]
 export type GrowiServiceType = typeof GrowiServiceType[keyof typeof GrowiServiceType]
 type GrowiWikiType = typeof GrowiWikiType[keyof typeof GrowiWikiType]
 type GrowiWikiType = typeof GrowiWikiType[keyof typeof GrowiWikiType]
 type GrowiAttachmentType = typeof GrowiAttachmentType[keyof typeof GrowiAttachmentType]
 type GrowiAttachmentType = typeof GrowiAttachmentType[keyof typeof GrowiAttachmentType]
 type GrowiDeploymentType = typeof GrowiDeploymentType[keyof typeof GrowiDeploymentType]
 type GrowiDeploymentType = typeof GrowiDeploymentType[keyof typeof GrowiDeploymentType]
+export type GrowiExternalAuthProviderType = typeof GrowiExternalAuthProviderType[keyof typeof GrowiExternalAuthProviderType]
 
 
 interface IGrowiOSInfo {
 interface IGrowiOSInfo {
   type?: ReturnType<typeof os.type>
   type?: ReturnType<typeof os.type>
@@ -45,7 +53,7 @@ export interface IGrowiInfo {
   currentActiveUsersCount: number
   currentActiveUsersCount: number
   wikiType: GrowiWikiType
   wikiType: GrowiWikiType
   attachmentType: GrowiAttachmentType
   attachmentType: GrowiAttachmentType
-  activeExternalAccountTypes?: string
+  activeExternalAccountTypes?: GrowiExternalAuthProviderType[]
   osInfo?: IGrowiOSInfo
   osInfo?: IGrowiOSInfo
   deploymentType?: GrowiDeploymentType
   deploymentType?: GrowiDeploymentType
 }
 }

+ 6 - 2
packages/app/src/server/service/questionnaire.ts

@@ -1,7 +1,7 @@
 import crypto from 'crypto';
 import crypto from 'crypto';
 import * as os from 'node:os';
 import * as os from 'node:os';
 
 
-import { GrowiWikiType, IGrowiInfo } from '~/interfaces/questionnaire/growi-info';
+import { GrowiWikiType, GrowiExternalAuthProviderType, IGrowiInfo } from '~/interfaces/questionnaire/growi-info';
 import { StatusType } from '~/interfaces/questionnaire/questionnaire-answer-status';
 import { StatusType } from '~/interfaces/questionnaire/questionnaire-answer-status';
 import { IUserInfo, UserType } from '~/interfaces/questionnaire/user-info';
 import { IUserInfo, UserType } from '~/interfaces/questionnaire/user-info';
 import { IUserHasId } from '~/interfaces/user';
 import { IUserHasId } from '~/interfaces/user';
@@ -34,6 +34,10 @@ class QuestionnaireService {
     const wikiMode = this.crowi.configManager.getConfig('crowi', 'security:wikiMode');
     const wikiMode = this.crowi.configManager.getConfig('crowi', 'security:wikiMode');
     const wikiType = wikiMode === 'private' ? GrowiWikiType.closed : GrowiWikiType.open;
     const wikiType = wikiMode === 'private' ? GrowiWikiType.closed : GrowiWikiType.open;
 
 
+    const activeExternalAccountTypes: GrowiExternalAuthProviderType[] = Object.values(GrowiExternalAuthProviderType).filter((type) => {
+      return this.crowi.configManager.getConfig('crowi', `security:passport-${type}:isEnabled`);
+    });
+
     return {
     return {
       version: this.crowi.version,
       version: this.crowi.version,
       osInfo: {
       osInfo: {
@@ -49,7 +53,7 @@ class QuestionnaireService {
       currentActiveUsersCount,
       currentActiveUsersCount,
       wikiType,
       wikiType,
       attachmentType: this.crowi.configManager.getConfig('crowi', 'app:fileUploadType'),
       attachmentType: this.crowi.configManager.getConfig('crowi', 'app:fileUploadType'),
-      activeExternalAccountTypes: undefined, // TODO: set actual value
+      activeExternalAccountTypes,
       deploymentType: this.crowi.configManager.getConfig('crowi', 'app:deploymentType'),
       deploymentType: this.crowi.configManager.getConfig('crowi', 'app:deploymentType'),
     };
     };
   }
   }