mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
Multiuser support (#60)
This commit is contained in:
27
app/actions/user.ts
Normal file
27
app/actions/user.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
"use server"
|
||||
|
||||
import { signIn as signInNextAuth, signOut as signOutNextAuth } from '@/auth';
|
||||
|
||||
export async function signIn(username: string, password: string) {
|
||||
try {
|
||||
const result = await signInNextAuth("credentials", {
|
||||
username,
|
||||
password,
|
||||
redirect: false, // This needs to be passed as an option, not as form data
|
||||
});
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
throw new Error("Invalid credentials");
|
||||
}
|
||||
}
|
||||
|
||||
export async function signOut() {
|
||||
try {
|
||||
const result = await signOutNextAuth({
|
||||
redirect: false,
|
||||
})
|
||||
} catch (error) {
|
||||
throw new Error("Failed to sign out");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user