fix: handle auth callback failures

This commit is contained in:
2569718930@qq.com
2026-06-05 16:50:52 +08:00
parent e6a1d14b09
commit 09979f3bb5
6 changed files with 105 additions and 4 deletions
+15 -2
View File
@@ -2,7 +2,7 @@ import { LoginClient } from "@/components/auth/LoginClient";
import { I18nProvider } from "@/hooks/useI18n";
type PageProps = {
searchParams?: Promise<{ next?: string; mode?: string }>;
searchParams?: Promise<{ error?: string; mode?: string; next?: string }>;
};
function normalizeNextPath(input: string | undefined) {
@@ -19,13 +19,26 @@ function normalizeMode(input: string | undefined): "login" | "signup" {
return "login";
}
function normalizeAuthError(input: string | undefined) {
const raw = String(input || "")
.replace(/[\r\n]+/g, " ")
.trim();
if (!raw) return "";
return raw.slice(0, 240);
}
export default async function LoginPage({ searchParams }: PageProps) {
const params = (await searchParams) || {};
const nextPath = normalizeNextPath(params.next);
const initialMode = normalizeMode(params.mode);
const initialError = normalizeAuthError(params.error);
return (
<I18nProvider>
<LoginClient nextPath={nextPath} initialMode={initialMode} />
<LoginClient
nextPath={nextPath}
initialMode={initialMode}
initialError={initialError}
/>
</I18nProvider>
);
}