@@ -28,10 +28,8 @@ export const authOptions: NextAuthOptions = { const { username, password } = credentials as any const resp = await AuthProxy.loginByEmail(username, password) - const data = await resp.json() - - if (resp.status >= 400 && resp.status < 500) { + if (resp.status >= 400 && resp.status < 500) { throw new Error( ERROR_MAPPING[(data as { detail: string }).detail] ?? JSON.stringify(data as Object) @@ -78,6 +76,25 @@ export const authOptions: NextAuthOptions = { } return Promise.resolve(true) + + // if (status >= 400 && status < 500) { + // console.log(result) + // throw new Error( + // ERROR_MAPPING[(result as { detail: string }).detail] ?? + // JSON.stringify(result as Object) + // .replace(/\s+/, '_') + // .replace(/[А-Яа-я]/, '') + // .toLowerCase() + // ) + + // return + // } + + // const data = result as { access_token: string } + + // const finalData = await getAll(data.access_token) + + // const { access, refresh } = finalData.token } return Promise.resolve(true) @@ -22,7 +22,6 @@ import { ERROR_MAPPING } from '#/pages/api/auth/constants' import OpenedEyeSvg from '#/assets/svg/opened-eye.svg?react' import ClosedEyeSvg from '#/assets/svg/closed-eye.svg?react' import * as Sentry from '@sentry/nextjs' -import { useEffect } from 'react' const Login: NextPageWithLayout = () => { const device = getDeviceType() @@ -45,14 +44,6 @@ const Login: NextPageWithLayout = () => { const { register, handleSubmit, getValues, reset } = useForm() - useEffect(() => { - const params = new URL(window.location.href).searchParams - - if (params.get('error')) { - showError(params.get('error')!) - } - }, []) - async function onSubmit(data: any) { setLoading(true) @@ -74,7 +65,8 @@ const Login: NextPageWithLayout = () => { {} as Record )[resp.error] showError(expectedError ?? 'Непредвиденная ошибка') - if (!expectedError) Sentry.captureMessage(resp.error) + if (!expectedError) + Sentry.captureMessage(resp.error) setLoading(false) } else { push('/')