diff --git a/src/app/(auth)/authorize/metadata.ts b/src/app/(auth)/authorize/metadata.ts deleted file mode 100644 index f2a0c02..0000000 --- a/src/app/(auth)/authorize/metadata.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Metadata } from "next"; - -export const metadata: Metadata = { - title: "Auth – Q58论坛", - description: "Sign in to your account", -}; diff --git a/src/app/(auth)/authorize/page.tsx b/src/app/(auth)/authorize/page.tsx index b1ac047..8c18541 100644 --- a/src/app/(auth)/authorize/page.tsx +++ b/src/app/(auth)/authorize/page.tsx @@ -1,11 +1,20 @@ -"use client"; - +import { Suspense } from "react"; +import { Metadata } from "next"; import Link from "next/link"; import { MessageCircleCode } from "lucide-react"; -import { UserAuthForm } from "@/components/auth/user-auth-form"; +import { UserAuthorize } from "@/components/auth/user-authorize"; -export default function AuthPage() { +type Props = { + searchParams: { [key: string]: string | string[] | undefined }; +}; + +export const metadata: Metadata = { + title: `Auth – Q58论坛`, + description: "Sign in to your account", +}; + +export default function AuthPage({ searchParams }: Props) { return (
By clicking continue, you agree to our{" "} { + React.startTransition(async () => { + const response = await fetch("/api/auth/q58", { method: "POST" }); + if (!response.ok || response.status !== 200) { + setIsLoading(false); + toast({ + variant: "destructive", + title: "内部服务异常", + description: response.statusText, + }); + } else { + let data: DiscourseData = await response.json(); + router.push(data.sso_url); } - - const data = await response.json(); - window.location.href = data.sso_url; - } catch (error) { - console.error("登录错误:", error); - toast({ - title: "登录失败", - description: "登录过程中发生错误,请稍后重试", - variant: "destructive", - }); - setIsLoading(false); - } - } + }); + }; return (