mirror of
https://github.com/woodchen-ink/Q58Connect.git
synced 2025-07-18 14:01:55 +08:00
28 lines
679 B
TypeScript
28 lines
679 B
TypeScript
"use server";
|
|
|
|
import { redirect } from "next/navigation";
|
|
import { signIn as nextSignIn } from "@/auth";
|
|
|
|
export async function signIn(data: Record<string, any>) {
|
|
const { sso, sig } = data;
|
|
|
|
try {
|
|
// 进行 SSO 登录
|
|
await nextSignIn("credentials", { sso, sig });
|
|
|
|
// 从 sso 参数中获取 return_sso_url
|
|
const params = new URLSearchParams(atob(sso));
|
|
const returnSsoUrl = params.get("return_sso_url");
|
|
|
|
if (!returnSsoUrl) {
|
|
redirect("/dashboard");
|
|
}
|
|
|
|
// 重定向到 return_sso_url
|
|
redirect(returnSsoUrl);
|
|
} catch (error) {
|
|
console.error("登录失败:", error);
|
|
redirect("/sign-in?error=AuthenticationError");
|
|
}
|
|
}
|