mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Authentication with Credentials is working and setup, same for OAuth with Google.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"use server"
|
||||
import {signIn, signOut} from "@/auth/auth";
|
||||
import {redirect} from "next/navigation";
|
||||
|
||||
export const signOutAction = async () => {
|
||||
await signOut({redirectTo: '/', redirect: true})
|
||||
window.location.reload();
|
||||
}
|
||||
export const signInAction = async (type: string, formData?: any) => {
|
||||
if (type === "google") {
|
||||
await signIn(type, {redirectTo: '/dashboard'})
|
||||
} else {
|
||||
try {
|
||||
await signIn(type, {
|
||||
redirect: false,
|
||||
password: formData.password,
|
||||
email: formData.email
|
||||
});
|
||||
} catch (error) {
|
||||
// const signInError = error as CredentialsSignin
|
||||
console.error(error);
|
||||
return {error: "Error loging in, please try again or check your credentials !"};
|
||||
}
|
||||
redirect("/")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user