Initial SeConectai briefing system

This commit is contained in:
2026-10-04 10:42:23 -03:00
commit 45cd8d2f03
163 changed files with 12659 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
"use server";
import { AuthError } from "next-auth";
import { redirect } from "next/navigation";
import { signIn } from "@/auth";
export type LoginState = {
ok: boolean;
message?: string;
};
export async function login(_state: LoginState, formData: FormData): Promise<LoginState> {
const callbackUrl = formData.get("callbackUrl")?.toString();
try {
await signIn("credentials", {
email: formData.get("email"),
senha: formData.get("senha"),
redirectTo: callbackUrl || undefined
});
} catch (error) {
if (error instanceof AuthError) {
return {
ok: false,
message: "E-mail ou senha invalidos."
};
}
throw error;
}
redirect(callbackUrl || "/briefings");
}