Error
Something went wrong.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user