From b4b20837235a832730ac7d91dd557000689cd54b Mon Sep 17 00:00:00 2001 From: Jaren Goldberg Date: Tue, 3 Oct 2023 17:38:16 -0400 Subject: [PATCH] fix --- pages/admin/sponsors/create.tsx | 39 +---------------------------- pages/admin/sponsors/index.tsx | 44 +-------------------------------- 2 files changed, 2 insertions(+), 81 deletions(-) diff --git a/pages/admin/sponsors/create.tsx b/pages/admin/sponsors/create.tsx index 7915471..7b0b3b5 100644 --- a/pages/admin/sponsors/create.tsx +++ b/pages/admin/sponsors/create.tsx @@ -25,7 +25,7 @@ const AdminCreateSponsors: NextPage<{ user: { email: string, has2faEnabled: bool url: data.url, }), }); - + if (req.ok) { console.log('ok'); } else if (req.status === 401) { @@ -91,31 +91,6 @@ const AdminCreateSponsors: NextPage<{ user: { email: string, has2faEnabled: bool export const getServerSideProps = withIronSessionSsr(async function ({ req, resolvedUrl }): Promise { const user = req?.session.user; - if (user?.email) { - const request = await fetch(`${process.env.NEXT_PUBLIC_DOMAIN}/api/auth/2fa/generate`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(user), - }); - - const json = await request.json(); - - if (json.data) return { - props: { - user: { email: user.email, has2faEnabled: true, completed2fa: false }, - otpAuthUri: json.data, - }, - }; - return { - props: { - user: { email: user.email, has2faEnabled: false, completed2fa: false }, - otpAuthUri: '', - }, - }; - } - if (!user) { return { props: { @@ -128,18 +103,6 @@ export const getServerSideProps = withIronSessionSsr(async function ({ req, reso }; } - if (!user.has2faEnabled) { - return { - props: { - user: { email: user.email, has2faEnabled: false, completed2fa: false }, - }, - redirect: { - destination: '/admin/settings', - permanent: false, - }, - }; - } - return { props: { user: req.session.user }, }; diff --git a/pages/admin/sponsors/index.tsx b/pages/admin/sponsors/index.tsx index 74e7c03..36f25d0 100644 --- a/pages/admin/sponsors/index.tsx +++ b/pages/admin/sponsors/index.tsx @@ -5,7 +5,7 @@ import InProgress from '../../../components/InProgress'; import { AdminProps } from '../../../src/types/index'; import { SponsorDocument } from '../../../src/models/Sponsor'; -const AdminSponsorsIndex: NextPage =() => { +const AdminSponsorsIndex: NextPage = () => { return ( ); @@ -26,36 +26,6 @@ export const getServerSideProps = withIronSessionSsr(async function ({ req, res, const data = await request.json(); - if (user?.email) { - const request = await fetch(`${process.env.NEXT_PUBLIC_DOMAIN}/api/auth/2fa/generate`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(user), - }); - - const json = await request.json(); - - if (json.data) return { - props: { - user: { email: user.email, has2faEnabled: true, completed2fa: false }, - otpAuthUri: json.data, - }, - }; - return { - props: { - user: { - email: user.email, - has2faEnabled: false, - completed2fa: false, - }, - otpAuthUri: '', - data: data.data, - }, - }; - } - if (!user) { return { props: { @@ -68,18 +38,6 @@ export const getServerSideProps = withIronSessionSsr(async function ({ req, res, }; } - if (!user.has2faEnabled) { - return { - props: { - user: { email: user.email, has2faEnabled: false, completed2fa: false }, - }, - redirect: { - destination: '/admin/settings', - permanent: false, - }, - }; - } - return { props: { user: req.session.user,