MeetUp/src/lib/auth/login.ts
Dominik Stahl 4e87c11ec3 feat: implement credentials login
implements the credentials login functionality
2025-06-14 09:57:28 +00:00

27 lines
534 B
TypeScript

'use server';
import { z } from 'zod';
import { loginSchema } from '@/lib/validation/user';
import { signIn } from '@/auth';
export async function loginAction(data: z.infer<typeof loginSchema>) {
try {
await signIn('credentials', {
...data,
redirect: false,
});
return {
error: undefined,
};
} catch (error: unknown) {
if (error instanceof Error) {
return {
error: error.message.toString(),
};
}
return {
error: 'An unknown error occurred.',
};
}
}