@@ -5,6 +5,8 @@ import YandexProvider from 'next-auth/providers/yandex' import { AuthConstants } from './constants' import { AuthorizationProxy } from './proxy' +import * as Sentry from '@sentry/nextjs' + const AuthProxy = new AuthorizationProxy() export const authOptions: NextAuthOptions = { @@ -42,10 +44,20 @@ export const authOptions: NextAuthOptions = { } if (user) { - token.access = user.token.access - token.refresh = user.token.refresh - token.tokenExpiry = AuthConstants.getExpiresDate() - return token + try { + token.access = user.token.access + token.refresh = user.token.refresh + token.tokenExpiry = AuthConstants.getExpiresDate() + return token + } catch (error) { + Sentry.captureMessage( + 'token not found ' + + error + + Object.keys(user) + .map((key) => `${key}=${user[key as keyof User]}`) + .join(';') + ) + } } const shouldRefreshTime = Math.round(Date.now() - token.tokenExpiry) >= 0 @@ -1,28 +1,26 @@ import * as React from 'react' -import { useCallback, useEffect } from 'react' import { useCookies } from 'react-cookie' import { useForm } from 'react-hook-form' import { SubmitErrorHandler } from 'react-hook-form/dist/types/form' import { Box, Button, Link, Stack, TextField, Typography } from '@mui/material' import CircularProgress from '@mui/material/CircularProgress' -import * as Sentry from '@sentry/browser' import Image from 'next/image' import { useRouter } from 'next/router' import Router from 'next/router' import Script from 'next/script' import { signIn } from 'next-auth/react' - -import styles from './login.module.scss' - -import { useAppSelector } from '#/app/store/store' import { authTelegram } from '#/features/auth-telegram' import { PasswordOptions } from '#/features/register-by-email/lib/constants' import { IEmailForms } from '#/features/register-by-email/model/types' -import { NextPageWithLayout } from '#/pages/_app' +import { useAppSelector } from '#/app/store/store' import { emailOptions, Error } from '#/shared' import { getDeviceType } from '#/shared/lib/helpers' import { useShowData } from '#/shared/lib/hooks' import { InputStyleDark, InputStyleLight } from '#/shared/ui/input' +import { NextPageWithLayout } from '#/pages/_app' +import * as Sentry from '@sentry/browser' +import styles from './login.module.scss' +import { useCallback, useEffect } from 'react' const Login: NextPageWithLayout = () => { const device = getDeviceType() @@ -141,7 +139,7 @@ const Login: NextPageWithLayout = () => {