Phase 3. 인증 및 공통 레이아웃 작업

This commit is contained in:
2026-06-09 23:37:33 +09:00
parent a93a6fa8e1
commit dbf9b3e180
17 changed files with 1092 additions and 71 deletions
+26
View File
@@ -0,0 +1,26 @@
"use server";
import { AuthError } from "next-auth";
import { redirect } from "next/navigation";
import { signIn } from "@/auth";
export async function loginAction(formData: FormData) {
const callbackUrl = String(formData.get("callbackUrl") ?? "/");
try {
await signIn("credentials", {
adminName: formData.get("adminName"),
password: formData.get("password"),
redirectTo: callbackUrl,
});
} catch (error) {
if (error instanceof AuthError) {
redirect(
`/login?error=CredentialsSignin&callbackUrl=${encodeURIComponent(callbackUrl)}`
);
}
throw error;
}
}