mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 05:51:55 +08:00
feat: Implement form-based SSO redirect for more reliable authentication flow
This commit is contained in:
parent
21a2a51ba6
commit
b9ace034bf
@ -20,6 +20,7 @@ export function UserAuthForm({
|
||||
const router = useRouter();
|
||||
const { toast } = useToast();
|
||||
const searchParams = useSearchParams();
|
||||
const formRef = React.useRef<HTMLFormElement>(null);
|
||||
|
||||
async function signIn() {
|
||||
try {
|
||||
@ -65,9 +66,11 @@ export function UserAuthForm({
|
||||
const data = await response.json();
|
||||
console.log("收到 SSO URL:", data.sso_url);
|
||||
|
||||
// 确保在跳转前重置加载状态
|
||||
setIsLoading(false);
|
||||
window.location.href = data.sso_url;
|
||||
// 使用表单提交方式跳转
|
||||
if (formRef.current) {
|
||||
formRef.current.action = data.sso_url;
|
||||
formRef.current.submit();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("登录错误:", error);
|
||||
toast({
|
||||
@ -84,6 +87,7 @@ export function UserAuthForm({
|
||||
|
||||
return (
|
||||
<div className={cn("grid gap-3", className)} {...props}>
|
||||
<form ref={formRef} method="get" style={{ display: "none" }} />
|
||||
<button
|
||||
type="button"
|
||||
className={cn(buttonVariants({ variant: "outline" }))}
|
||||
|
Loading…
x
Reference in New Issue
Block a user