Something went wrong.
This commit is contained in:
Leon Serfaty G
2025-09-01 07:09:54 +00:00
parent 33d5b67f97
commit 71995d0632
+4 -4
View File
@@ -1,7 +1,7 @@
'use server';
import { signIn, signOut } from '@/auth';
import { AuthError } from 'next-auth';
export async function login(
prevState: { message: string } | undefined,
@@ -9,13 +9,13 @@ export async function login(
) {
try {
await signIn('credentials', formData);
} catch (error: any) {
if (error) {
} catch (error) {
if (error instanceof AuthError) {
switch (error.type) {
case 'CredentialsSignin':
return { message: 'Invalid credentials.' };
default:
return { message: 'Something went wrong.' };
return { message: 'Something went wrong. Please try again.' };
}
}
throw error;