Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(web): gate plugin auth permission hint (#39721)

非法操作e604fad630fa
diff --git a/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx b/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx
index 1423f3896d5..c7175a1ba76 100644
--- a/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx
+++ b/web/app/components/plugins/plugin-auth/__tests__/plugin-auth.spec.tsx
@@ -68,6 +68,7 @@ describe('PluginAuth', () => {
render(<PluginAuth pluginPayload={defaultPayload} />)
expect(screen.getByRole('button', { name: 'plugin.auth.useApiAuth' })).toBeEnabled()
+ expect(screen.queryByText('plugin.auth.permissionHint.title')).not.toBeInTheDocument()
expect(screen.queryByTestId('authorized')).not.toBeInTheDocument()
})
diff --git a/web/app/components/plugins/plugin-auth/plugin-auth.tsx b/web/app/components/plugins/plugin-auth/plugin-auth.tsx
index 66441fa2d33..d84595809aa 100644
--- a/web/app/components/plugins/plugin-auth/plugin-auth.tsx
+++ b/web/app/components/plugins/plugin-auth/plugin-auth.tsx
@@ -4,6 +4,7 @@ import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import { ACCOUNT_SETTING_TAB } from '@/app/components/header/account-setting/constants'
import { useModalContext } from '@/context/modal-context'
+import { useCredentialPermissions } from '@/hooks/use-credential-permissions'
import Authorize from './authorize'
import Authorized from './authorized'
import { usePluginAuth } from './hooks/use-plugin-auth'
@@ -17,6 +18,7 @@ type PluginAuthProps = {
const PluginAuth = ({ pluginPayload, children, className }: PluginAuthProps) => {
const { t } = useTranslation()
const { setShowAccountSettingModal } = useModalContext()
+ const { canCreateCredential } = useCredentialPermissions()
const {
isAuthorized,
canOAuth,
@@ -27,6 +29,7 @@ const PluginAuth = ({ pluginPayload, children, className }: PluginAuthProps) =>
} = usePluginAuth(pluginPayload, !!pluginPayload.provider)
const showPermissionHint =
!isAuthorized &&
+ !canCreateCredential &&
!notAllowCustomCredential &&
pluginPayload.category === AuthCategory.tool &&
(canOAuth || canApiKey)