From 63b74c17df199463d7a953b902733ea961d284ed Mon Sep 17 00:00:00 2001 From: twwu Date: Mon, 27 Oct 2025 18:46:29 +0800 Subject: [PATCH] feat: enhance plugin authentication by adding providerType to PluginPayload and integrating invalid tools handling --- .../plugins/plugin-auth/hooks/use-credential.ts | 9 ++++++++- web/app/components/plugins/plugin-auth/types.ts | 3 +++ .../nodes/_base/components/workflow-panel/index.tsx | 2 ++ web/service/use-tools.ts | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/web/app/components/plugins/plugin-auth/hooks/use-credential.ts b/web/app/components/plugins/plugin-auth/hooks/use-credential.ts index 5a7a497ad9..9c342f2ced 100644 --- a/web/app/components/plugins/plugin-auth/hooks/use-credential.ts +++ b/web/app/components/plugins/plugin-auth/hooks/use-credential.ts @@ -15,6 +15,7 @@ import { import { useGetApi } from './use-get-api' import type { PluginPayload } from '../types' import type { CredentialTypeEnum } from '../types' +import { useInvalidToolsByType } from '@/service/use-tools' export const useGetPluginCredentialInfoHook = (pluginPayload: PluginPayload, enable?: boolean) => { const apiMap = useGetApi(pluginPayload) @@ -29,8 +30,14 @@ export const useDeletePluginCredentialHook = (pluginPayload: PluginPayload) => { export const useInvalidPluginCredentialInfoHook = (pluginPayload: PluginPayload) => { const apiMap = useGetApi(pluginPayload) + const invalidPluginCredentialInfo = useInvalidPluginCredentialInfo(apiMap.getCredentialInfo) + const providerType = pluginPayload.providerType + const invalidToolsByType = useInvalidToolsByType(providerType) - return useInvalidPluginCredentialInfo(apiMap.getCredentialInfo) + return () => { + invalidPluginCredentialInfo() + invalidToolsByType() + } } export const useSetPluginDefaultCredentialHook = (pluginPayload: PluginPayload) => { diff --git a/web/app/components/plugins/plugin-auth/types.ts b/web/app/components/plugins/plugin-auth/types.ts index 6366c80de3..fb23269b4b 100644 --- a/web/app/components/plugins/plugin-auth/types.ts +++ b/web/app/components/plugins/plugin-auth/types.ts @@ -1,3 +1,5 @@ +import type { CollectionType } from '../../tools/types' + export type { AddApiKeyButtonProps } from './authorize/add-api-key-button' export type { AddOAuthButtonProps } from './authorize/add-oauth-button' @@ -10,6 +12,7 @@ export enum AuthCategory { export type PluginPayload = { category: AuthCategory provider: string + providerType: CollectionType | string } export enum CredentialTypeEnum { diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx index 3ab6b29b01..29aebd4fd5 100644 --- a/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx +++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/index.tsx @@ -451,6 +451,7 @@ const BasePanel: FC = ({ className='px-4 pb-2' pluginPayload={{ provider: currCollection?.name || '', + providerType: currCollection?.type || '', category: AuthCategory.tool, }} > @@ -462,6 +463,7 @@ const BasePanel: FC = ({ = { [CollectionType.workflow]: useAllWorkflowToolsKey, [CollectionType.mcp]: useAllMCPToolsKey, } -export const useInvalidToolsByType = (type: CollectionType) => { +export const useInvalidToolsByType = (type: CollectionType | string) => { return useInvalid(useInvalidToolsKeyMap[type]) }