chore: bump next-auth (#491)

* chore: bump `next-auth`

* shorten message
This commit is contained in:
Balázs Orbán
2023-11-29 13:44:04 +01:00
committed by GitHub
parent 7fc5092ca2
commit e75f71499f
3 changed files with 13 additions and 7 deletions

View File

@@ -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;
}