From cc5adb3702ebc16e639863190e515b612658303c Mon Sep 17 00:00:00 2001 From: atrincas Date: Tue, 7 Jan 2025 10:31:16 +0100 Subject: [PATCH] fix: missing correct error message on failed sigin --- client/src/pages/api/auth/[...nextauth].ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/client/src/pages/api/auth/[...nextauth].ts b/client/src/pages/api/auth/[...nextauth].ts index c32074f..adc19ca 100644 --- a/client/src/pages/api/auth/[...nextauth].ts +++ b/client/src/pages/api/auth/[...nextauth].ts @@ -1,4 +1,3 @@ -import axios from 'axios'; import { NextApiRequest, NextApiResponse } from 'next'; import { GetServerSidePropsContext } from 'next'; import NextAuth, { getServerSession } from 'next-auth'; @@ -40,18 +39,9 @@ export const authOptions: NextAuthOptions = { async authorize(credentials: Record<'email' | 'password', string> | undefined) { if (!credentials) return null; const { email, password } = credentials; + const { data } = await authenticationService.signIn(email, password); - try { - const { data } = await authenticationService.signIn(email, password); - - return data; - } catch (err) { - if (axios.isAxiosError(err) && err.response) { - const errorMessage = err.response.data?.errors[0]?.title || 'Login failed'; - throw new Error(errorMessage); - } - throw new Error('An unexpected error occurred'); - } + return data; }, }), ],