From a645dc7ba5cd37ef75498aec1f84f13a6fdcf190 Mon Sep 17 00:00:00 2001 From: Syed Abdullah <2syedabdullah@gmail.com> Date: Fri, 28 Nov 2025 06:10:19 +0000 Subject: [PATCH 1/4] Issue#3802 - Team to user switch fixed --- src/app/page.tsx | 8 +++----- src/components/input/NavButton.tsx | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 8bf748f9..06998956 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,7 +1,7 @@ 'use client'; import { useEffect } from 'react'; import { redirect } from 'next/navigation'; -import { getItem, removeItem } from '@/lib/storage'; +import { getItem } from '@/lib/storage'; import { LAST_TEAM_CONFIG } from '@/lib/constants'; export default function RootPage() { @@ -10,11 +10,9 @@ export default function RootPage() { if (lastTeam) { redirect(`/teams/${lastTeam}/websites`); - } else { - removeItem(LAST_TEAM_CONFIG); - - redirect(`/websites`); } + + redirect(`/websites`); }, []); return null; diff --git a/src/components/input/NavButton.tsx b/src/components/input/NavButton.tsx index b57c2ecd..44496e22 100644 --- a/src/components/input/NavButton.tsx +++ b/src/components/input/NavButton.tsx @@ -93,7 +93,7 @@ export function NavButton({ showText = true }: TeamsButtonProps) { - + } label={user.username} /> From 50bfee33284e716a888298078a03ca3f656c2bbd Mon Sep 17 00:00:00 2001 From: Syed Abdullah <2syedabdullah@gmail.com> Date: Fri, 28 Nov 2025 06:30:22 +0000 Subject: [PATCH 2/4] Moved the redirect to else statement --- src/app/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 06998956..22f6bc84 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -10,9 +10,9 @@ export default function RootPage() { if (lastTeam) { redirect(`/teams/${lastTeam}/websites`); + } else { + redirect(`/websites`); } - - redirect(`/websites`); }, []); return null; From 4d70c3baf1e4bd366e60ccee8c97da56ce3fae54 Mon Sep 17 00:00:00 2001 From: Indra Gunawan Date: Mon, 1 Dec 2025 16:48:58 +0800 Subject: [PATCH 3/4] add support for UUID v7 --- src/lib/crypto.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts index f9387460..f6b0248e 100644 --- a/src/lib/crypto.ts +++ b/src/lib/crypto.ts @@ -1,5 +1,5 @@ import crypto from 'crypto'; -import { v4, v5 } from 'uuid'; +import { v4, v5, v7 } from 'uuid'; const ALGORITHM = 'aes-256-gcm'; const IV_LENGTH = 16; @@ -57,7 +57,9 @@ export function secret() { } export function uuid(...args: any) { - if (!args.length) return v4(); + if (args.length) { + return v5(hash(...args, secret()), v5.DNS); + } - return v5(hash(...args, secret()), v5.DNS); + return process.env.USE_UUIDV7 ? v7() : v4(); } From f5896f071bf3e69c245fa5de8dac9f470e3bdc85 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Mon, 1 Dec 2025 23:33:57 -0800 Subject: [PATCH 4/4] Handle user account redirect. --- pnpm-lock.yaml | 2 ++ src/app/page.tsx | 1 - src/components/input/NavButton.tsx | 23 +++++++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a4577c1..e19b4029 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -328,6 +328,8 @@ importers: specifier: ^5.9.3 version: 5.9.3 + dist: {} + packages: '@ampproject/remapping@2.3.0': diff --git a/src/app/page.tsx b/src/app/page.tsx index 24a27116..6f0033df 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,6 +1,5 @@ 'use client'; import { redirect } from 'next/navigation'; -import { getItem } from '@/lib/storage'; import { useEffect } from 'react'; import { LAST_TEAM_CONFIG } from '@/lib/constants'; import { getItem } from '@/lib/storage'; diff --git a/src/components/input/NavButton.tsx b/src/components/input/NavButton.tsx index 9552ac73..ab77ef06 100644 --- a/src/components/input/NavButton.tsx +++ b/src/components/input/NavButton.tsx @@ -14,6 +14,7 @@ import { Text, } from '@umami/react-zen'; import { ArrowRight } from 'lucide-react'; +import type { Key } from 'react'; import { useConfig, useLoginQuery, @@ -33,7 +34,8 @@ import { Users, } from '@/components/icons'; import { Switch } from '@/components/svg'; -import { DOCS_URL } from '@/lib/constants'; +import { DOCS_URL, LAST_TEAM_CONFIG } from '@/lib/constants'; +import { removeItem } from '@/lib/storage'; export interface TeamsButtonProps { showText?: boolean; @@ -44,7 +46,7 @@ export function NavButton({ showText = true }: TeamsButtonProps) { const { user } = useLoginQuery(); const { cloudMode } = useConfig(); const { formatMessage, labels } = useMessages(); - const { teamId } = useNavigation(); + const { teamId, router } = useNavigation(); const { isMobile } = useMobile(); const team = user?.teams?.find(({ id }) => id === teamId); const selectedKeys = new Set([teamId || 'user']); @@ -54,7 +56,16 @@ export function NavButton({ showText = true }: TeamsButtonProps) { return cloudMode ? `${process.env.cloudUrl}${url}` : url; }; - const handleAction = async () => {}; + const handleAction = async (key: Key) => { + if (key === 'user') { + removeItem(LAST_TEAM_CONFIG); + if (cloudMode) { + window.location.href = '/'; + } else { + router.push('/'); + } + } + }; return ( @@ -84,16 +95,16 @@ export function NavButton({ showText = true }: TeamsButtonProps) { - + } label={formatMessage(labels.switchAccount)} /> - + - + } label={user.username} />