From 46d45e4c396d6deac0c0802a703a17172126c697 Mon Sep 17 00:00:00 2001 From: Stephen Zhou Date: Sun, 1 Mar 2026 14:29:23 +0800 Subject: [PATCH] fix: remove REDIRECT_URL_KEY from url (#32770) --- web/app/account/oauth/authorize/constants.ts | 3 -- web/app/account/oauth/authorize/page.tsx | 27 ++++-------- web/app/components/app-initializer.tsx | 2 +- web/app/signin/check-code/page.tsx | 10 ++--- .../components/mail-and-password-auth.tsx | 6 +-- web/app/signin/invite-settings/page.tsx | 16 +++---- web/app/signin/normal-form.tsx | 42 +++++++++---------- web/app/signin/utils/post-login-redirect.ts | 40 ++++-------------- web/eslint-suppressions.json | 21 ---------- 9 files changed, 54 insertions(+), 113 deletions(-) delete mode 100644 web/app/account/oauth/authorize/constants.ts diff --git a/web/app/account/oauth/authorize/constants.ts b/web/app/account/oauth/authorize/constants.ts deleted file mode 100644 index f1d8b98ef4..0000000000 --- a/web/app/account/oauth/authorize/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const OAUTH_AUTHORIZE_PENDING_KEY = 'oauth_authorize_pending' -export const REDIRECT_URL_KEY = 'oauth_redirect_url' -export const OAUTH_AUTHORIZE_PENDING_TTL = 60 * 3 diff --git a/web/app/account/oauth/authorize/page.tsx b/web/app/account/oauth/authorize/page.tsx index c923d6457a..d718e0941d 100644 --- a/web/app/account/oauth/authorize/page.tsx +++ b/web/app/account/oauth/authorize/page.tsx @@ -7,7 +7,6 @@ import { RiMailLine, RiTranslate2, } from '@remixicon/react' -import dayjs from 'dayjs' import { useRouter, useSearchParams } from 'next/navigation' import * as React from 'react' import { useEffect, useRef } from 'react' @@ -17,22 +16,10 @@ import Button from '@/app/components/base/button' import Loading from '@/app/components/base/loading' import Toast from '@/app/components/base/toast' import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks' +import { setPostLoginRedirect } from '@/app/signin/utils/post-login-redirect' import { useAppContext } from '@/context/app-context' import { useIsLogin } from '@/service/use-common' import { useAuthorizeOAuthApp, useOAuthAppInfo } from '@/service/use-oauth' -import { - OAUTH_AUTHORIZE_PENDING_KEY, - OAUTH_AUTHORIZE_PENDING_TTL, - REDIRECT_URL_KEY, -} from './constants' - -function setItemWithExpiry(key: string, value: string, ttl: number) { - const item = { - value, - expiry: dayjs().add(ttl, 'seconds').unix(), - } - localStorage.setItem(key, JSON.stringify(item)) -} function buildReturnUrl(pathname: string, search: string) { try { @@ -86,8 +73,8 @@ export default function OAuthAuthorize() { const onLoginSwitchClick = () => { try { const returnUrl = buildReturnUrl('/account/oauth/authorize', `?client_id=${encodeURIComponent(client_id)}&redirect_uri=${encodeURIComponent(redirect_uri)}`) - setItemWithExpiry(OAUTH_AUTHORIZE_PENDING_KEY, returnUrl, OAUTH_AUTHORIZE_PENDING_TTL) - router.push(`/signin?${REDIRECT_URL_KEY}=${encodeURIComponent(returnUrl)}`) + setPostLoginRedirect(returnUrl) + router.push('/signin') } catch { router.push('/signin') @@ -145,7 +132,7 @@ export default function OAuthAuthorize() {
{authAppInfo?.app_label[language] || authAppInfo?.app_label?.en_US || t('unknownApp', { ns: 'oauth' })}
{!isLoggedIn &&
{t('tips.notLoggedIn', { ns: 'oauth' })}
} -
{isLoggedIn ? `${authAppInfo?.app_label[language] || authAppInfo?.app_label?.en_US || t('unknownApp', { ns: 'oauth' })} ${t('tips.loggedIn', { ns: 'oauth' })}` : t('tips.needLogin', { ns: 'oauth' })}
+
{isLoggedIn ? `${authAppInfo?.app_label[language] || authAppInfo?.app_label?.en_US || t('unknownApp', { ns: 'oauth' })} ${t('tips.loggedIn', { ns: 'oauth' })}` : t('tips.needLogin', { ns: 'oauth' })}
{isLoggedIn && userProfile && ( @@ -154,7 +141,7 @@ export default function OAuthAuthorize() {
{userProfile.name}
-
{userProfile.email}
+
{userProfile.email}
@@ -166,7 +153,7 @@ export default function OAuthAuthorize() { {authAppInfo!.scope.split(/\s+/).filter(Boolean).map((scope: string) => { const Icon = SCOPE_INFO_MAP[scope] return ( -
+
{Icon ? : } {Icon.label}
@@ -199,7 +186,7 @@ export default function OAuthAuthorize() {
-
{t('tips.common', { ns: 'oauth' })}
+
{t('tips.common', { ns: 'oauth' })}
) } diff --git a/web/app/components/app-initializer.tsx b/web/app/components/app-initializer.tsx index dfbac5d743..e4cd10175a 100644 --- a/web/app/components/app-initializer.tsx +++ b/web/app/components/app-initializer.tsx @@ -84,7 +84,7 @@ export const AppInitializer = ({ return } - const redirectUrl = resolvePostLoginRedirect(searchParams) + const redirectUrl = resolvePostLoginRedirect() if (redirectUrl) { location.replace(redirectUrl) return diff --git a/web/app/signin/check-code/page.tsx b/web/app/signin/check-code/page.tsx index 59579a76ec..24ac92157e 100644 --- a/web/app/signin/check-code/page.tsx +++ b/web/app/signin/check-code/page.tsx @@ -57,7 +57,7 @@ export default function CheckCode() { router.replace(`/signin/invite-settings?${searchParams.toString()}`) } else { - const redirectUrl = resolvePostLoginRedirect(searchParams) + const redirectUrl = resolvePostLoginRedirect() router.replace(redirectUrl || '/apps') } } @@ -95,8 +95,8 @@ export default function CheckCode() {
-

{t('checkCode.checkYourEmail', { ns: 'login' })}

-

+

{t('checkCode.checkYourEmail', { ns: 'login' })}

+

{t('checkCode.tipsPrefix', { ns: 'login' })} {email} @@ -107,7 +107,7 @@ export default function CheckCode() {

- + - {t('back', { ns: 'login' })} + {t('back', { ns: 'login' })} ) diff --git a/web/app/signin/components/mail-and-password-auth.tsx b/web/app/signin/components/mail-and-password-auth.tsx index 92165bb65b..877720b691 100644 --- a/web/app/signin/components/mail-and-password-auth.tsx +++ b/web/app/signin/components/mail-and-password-auth.tsx @@ -78,7 +78,7 @@ export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegis router.replace(`/signin/invite-settings?${searchParams.toString()}`) } else { - const redirectUrl = resolvePostLoginRedirect(searchParams) + const redirectUrl = resolvePostLoginRedirect() router.replace(redirectUrl || '/apps') } } @@ -105,7 +105,7 @@ export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegis return (
-
@@ -130,8 +130,8 @@ const NormalForm = () => { -

{t('licenseInactive', { ns: 'login' })}

-

{t('licenseInactiveTip', { ns: 'login' })}

+

{t('licenseInactive', { ns: 'login' })}

+

{t('licenseInactiveTip', { ns: 'login' })}

@@ -144,12 +144,12 @@ const NormalForm = () => { {isInviteLink ? (
-

+

{t('join', { ns: 'login' })} {workspaceName}

{!systemFeatures.branding.enabled && ( -

+

{t('joinTipStart', { ns: 'login' })} {workspaceName} {t('joinTipEnd', { ns: 'login' })} @@ -159,8 +159,8 @@ const NormalForm = () => { ) : (

-

{systemFeatures.branding.enabled ? t('pageTitleForE', { ns: 'login' }) : t('pageTitle', { ns: 'login' })}

-

{t('welcome', { ns: 'login' })}

+

{systemFeatures.branding.enabled ? t('pageTitleForE', { ns: 'login' }) : t('pageTitle', { ns: 'login' })}

+

{t('welcome', { ns: 'login' })}

)}
@@ -177,7 +177,7 @@ const NormalForm = () => {
- {t('or', { ns: 'login' })} + {t('or', { ns: 'login' })}
@@ -190,7 +190,7 @@ const NormalForm = () => { {systemFeatures.enable_email_password_login && (
{ updateAuthType('password') }}> - {t('usePassword', { ns: 'login' })} + {t('usePassword', { ns: 'login' })}
)} @@ -200,7 +200,7 @@ const NormalForm = () => { {systemFeatures.enable_email_code_login && (
{ updateAuthType('code') }}> - {t('useVerificationCode', { ns: 'login' })} + {t('useVerificationCode', { ns: 'login' })}
)} @@ -227,8 +227,8 @@ const NormalForm = () => {
-

{t('noLoginMethod', { ns: 'login' })}

-

{t('noLoginMethodTip', { ns: 'login' })}

+

{t('noLoginMethod', { ns: 'login' })}

+

{t('noLoginMethodTip', { ns: 'login' })}