mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-26 21:34:19 +00:00
28 lines
534 B
TypeScript
28 lines
534 B
TypeScript
"use server";
|
|
|
|
import { AuthError } from "next-auth";
|
|
|
|
import { signIn } from "@/auth.config";
|
|
|
|
// ...
|
|
|
|
export async function authenticate(
|
|
prevState: string | undefined,
|
|
formData: FormData,
|
|
) {
|
|
try {
|
|
console.log(formData);
|
|
await signIn("credentials", formData);
|
|
} catch (error) {
|
|
if (error instanceof AuthError) {
|
|
switch (error.type) {
|
|
case "CredentialsSignin":
|
|
return "Invalid credentials.";
|
|
default:
|
|
return "Something went wrong.";
|
|
}
|
|
}
|
|
throw error;
|
|
}
|
|
}
|