From 86f374df58aa3a88a0012e286a16a5c7ef320a1f Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Thu, 26 Jun 2025 03:51:19 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(auth):=20prevent=20duplicate?= =?UTF-8?q?=20=E2=80=9Csession=20expired=E2=80=9D=20toast=20on=20login?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Login Form used to display the message “未登录或登录已过期,请重新登录” twice because the `useEffect` that inspects the `expired` query parameter was re-executed on every re-render (e.g. language change or React StrictMode’s double-mount in development). ### What's changed • **LoginForm.js** – `useEffect` that shows the toast now has an empty dependency array so it runs only once on initial mount. • Reviewed **PasswordResetConfirm.js**, **PasswordResetForm.js** and **RegisterForm.js** and confirmed they do not contain the same issue; no changes were required. ### Impact Users now see the “session expired” notification exactly once, removing confusion and improving the overall UX. --- web/src/components/auth/LoginForm.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/auth/LoginForm.js b/web/src/components/auth/LoginForm.js index 7bd51dba..5128728c 100644 --- a/web/src/components/auth/LoginForm.js +++ b/web/src/components/auth/LoginForm.js @@ -84,7 +84,7 @@ const LoginForm = () => { if (searchParams.get('expired')) { showError(t('未登录或登录已过期,请重新登录')); } - }, [searchParams, t]); + }, []); const onWeChatLoginClicked = () => { setWechatLoading(true);