mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-30 16:14:17 +00:00
chore: bump next-auth (#491)
* chore: bump `next-auth` * shorten message
This commit is contained in:
@@ -5,6 +5,7 @@ import { sql } from '@vercel/postgres';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { signIn } from '@/auth';
|
||||
import { AuthError } from 'next-auth';
|
||||
|
||||
const FormSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -124,10 +125,15 @@ export async function authenticate(
|
||||
formData: FormData,
|
||||
) {
|
||||
try {
|
||||
await signIn('credentials', Object.fromEntries(formData));
|
||||
await signIn('credentials', formData);
|
||||
} catch (error) {
|
||||
if ((error as Error).message.includes('CredentialsSignin')) {
|
||||
return 'CredentialsSignin';
|
||||
if (error instanceof AuthError) {
|
||||
switch (error.type) {
|
||||
case 'CredentialsSignin':
|
||||
return 'Invalid credentials.';
|
||||
default:
|
||||
return 'Something went wrong.';
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user