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.

refactor(web): migrate account education notice storage (#36991)

Myshkin451d6b4c800c215
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index ec78d88f11e..9e66e966598 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -2507,11 +2507,6 @@
"count": 1
}
},
- "web/app/components/header/account-dropdown/index.tsx": {
- "no-restricted-globals": {
- "count": 3
- }
- },
"web/app/components/header/account-setting/data-source-page-new/card.tsx": {
"ts/no-explicit-any": {
"count": 2
diff --git a/web/app/components/header/account-dropdown/index.tsx b/web/app/components/header/account-dropdown/index.tsx
index b706fd33cca..896f7416ce4 100644
--- a/web/app/components/header/account-dropdown/index.tsx
+++ b/web/app/components/header/account-dropdown/index.tsx
@@ -18,6 +18,7 @@ import { useModalContext } from '@/context/modal-context'
import { useProviderContext } from '@/context/provider-context'
import { env } from '@/env'
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
+import { useSetLocalStorage } from '@/hooks/use-local-storage'
import Link from '@/next/link'
import { useRouter } from '@/next/navigation'
import { useLogout } from '@/service/use-common'
@@ -27,6 +28,10 @@ import Compliance from './compliance'
import { ExternalLinkIndicator, MenuItemContent } from './menu-item-content'
import Support from './support'
+const EDUCATION_REVERIFY_PREV_EXPIRE_AT_KEY = 'education-reverify-prev-expire-at'
+const EDUCATION_REVERIFY_HAS_NOTICED_KEY = 'education-reverify-has-noticed'
+const EDUCATION_EXPIRED_HAS_NOTICED_KEY = 'education-expired-has-noticed'
+
type AccountMenuRouteItemProps = {
href: string
iconClassName: string
@@ -116,6 +121,9 @@ export default function AppSelector() {
const { userProfile, langGeniusVersionInfo, isCurrentWorkspaceOwner } = useAppContext()
const { isEducationAccount } = useProviderContext()
const { setShowAccountSettingModal } = useModalContext()
+ const clearEducationReverifyPrevExpireAt = useSetLocalStorage<number>(EDUCATION_REVERIFY_PREV_EXPIRE_AT_KEY)
+ const clearEducationReverifyHasNoticed = useSetLocalStorage<boolean>(EDUCATION_REVERIFY_HAS_NOTICED_KEY)
+ const clearEducationExpiredHasNoticed = useSetLocalStorage<boolean>(EDUCATION_EXPIRED_HAS_NOTICED_KEY)
const { mutateAsync: logout } = useLogout()
const handleLogout = async () => {
@@ -124,9 +132,9 @@ export default function AppSelector() {
// Tokens are now stored in cookies and cleared by backend
// To avoid use other account's education notice info
- localStorage.removeItem('education-reverify-prev-expire-at')
- localStorage.removeItem('education-reverify-has-noticed')
- localStorage.removeItem('education-expired-has-noticed')
+ clearEducationReverifyPrevExpireAt(null)
+ clearEducationReverifyHasNoticed(null)
+ clearEducationExpiredHasNoticed(null)
router.push('/signin')
}