mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-16 16:34:24 +00:00
31 lines
656 B
TypeScript
31 lines
656 B
TypeScript
"use server";
|
|
|
|
import { AuthError } from "next-auth";
|
|
|
|
import { signIn, signOut } from "@/auth.config";
|
|
|
|
export async function authenticate(
|
|
prevState: string | undefined,
|
|
formData: FormData,
|
|
) {
|
|
try {
|
|
// await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
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;
|
|
}
|
|
}
|
|
|
|
export async function logOut() {
|
|
await signOut();
|
|
}
|