From a5a9f2e779eaa4494a7c8b860ba5699c0cabf2fa Mon Sep 17 00:00:00 2001 From: wood chen Date: Fri, 21 Feb 2025 16:27:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=AE=80=E5=8C=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=88=E6=9D=83=E7=BB=84=E4=BB=B6=E7=9A=84=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A7=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E5=BB=B6=E8=BF=9F=E5=92=8C=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/auth/user-authorize.tsx | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/components/auth/user-authorize.tsx b/src/components/auth/user-authorize.tsx index 52bb7c9..09ec2b5 100644 --- a/src/components/auth/user-authorize.tsx +++ b/src/components/auth/user-authorize.tsx @@ -32,36 +32,21 @@ export function UserAuthorize({ const sso = url.searchParams.get("sso"); const sig = url.searchParams.get("sig"); - console.log("准备登录,参数:", { - sso: sso?.substring(0, 20) + "...", - sig: sig?.substring(0, 20) + "...", - }); - if (!sso || !sig) { throw new Error("缺少必要的认证参数"); } + // 直接调用signIn,它会处理SSO回调中的return_sso_url await signIn({ sso, sig }); - // 更新 session + // 更新session状态 await update(); - // 添加更长的延迟确保session完全更新 - await new Promise((resolve) => setTimeout(resolve, 1000)); - // 检查URL中是否存在重定向参数 - const redirectTo = url.searchParams.get("redirect_to"); - if (redirectTo) { - // 如果存在重定向参数,则跳转到指定的URL - window.location.href = redirectTo; - } else { - // 如果不存在重定向参数,则刷新当前页面状态 - router.refresh(); - } setIsLoading(false); } catch (error) { console.error("登录过程出错:", error); setError(error); setIsLoading(false); } - }, [isLoading, update, router]); + }, [isLoading, update]); useEffect(() => { const timer = setTimeout(signInCallback, 5);