From 3f622fe277ef967327ba1a567a82bc6af54d7b0d Mon Sep 17 00:00:00 2001 From: Benny Joo Date: Mon, 27 Jan 2025 09:59:26 +0000 Subject: [PATCH] chore: migrate `/auth/verify` (#18902) * migrate /auth/verify page * update middleware --- apps/web/app/future/auth/verify/page.tsx | 22 ++++------------ apps/web/middleware.ts | 1 + apps/web/modules/auth/verify-view.tsx | 25 +++---------------- apps/web/pages/auth/verify.tsx | 9 ------- .../lib/auth/verify/getServerSideProps.tsx | 11 -------- 5 files changed, 10 insertions(+), 58 deletions(-) delete mode 100644 apps/web/pages/auth/verify.tsx delete mode 100644 apps/web/server/lib/auth/verify/getServerSideProps.tsx diff --git a/apps/web/app/future/auth/verify/page.tsx b/apps/web/app/future/auth/verify/page.tsx index b9870fab5f..b9862497c8 100644 --- a/apps/web/app/future/auth/verify/page.tsx +++ b/apps/web/app/future/auth/verify/page.tsx @@ -1,14 +1,9 @@ -import { withAppDirSsr } from "app/WithAppDirSsr"; import type { PageProps as _PageProps } from "app/_types"; import { _generateMetadata } from "app/_utils"; -import { WithLayout } from "app/layoutHOC"; import { z } from "zod"; import { StripeService } from "@calcom/lib/server/service/stripe"; -import { getServerSideProps } from "@server/lib/auth/verify/getServerSideProps"; - -import type { PageProps } from "~/auth/verify-view"; import VerifyPage from "~/auth/verify-view"; const querySchema = z.object({ @@ -21,13 +16,6 @@ export const generateMetadata = async ({ params, searchParams }: _PageProps) => const p = { ...params, ...searchParams }; const { sessionId, stripeCustomerId } = querySchema.parse(p); - if (!stripeCustomerId && !sessionId) { - return await _generateMetadata( - () => "Verify", - () => "" - ); - } - const data = await StripeService.getCheckoutSession({ stripeCustomerId, checkoutSessionId: sessionId, @@ -42,8 +30,8 @@ export const generateMetadata = async ({ params, searchParams }: _PageProps) => ); }; -export default WithLayout({ - getLayout: null, - Page: VerifyPage, - getData: withAppDirSsr(getServerSideProps), -})<"P">; +const ServerPage = () => { + return ; +}; + +export default ServerPage; diff --git a/apps/web/middleware.ts b/apps/web/middleware.ts index d59793689e..ccaeee526b 100644 --- a/apps/web/middleware.ts +++ b/apps/web/middleware.ts @@ -161,6 +161,7 @@ export const config = { "/auth/oauth2/authorize", "/auth/platform/authorize", "/auth/verify-email", + "/auth/verify", /** * Paths required by routingForms.handle */ diff --git a/apps/web/modules/auth/verify-view.tsx b/apps/web/modules/auth/verify-view.tsx index 327cefb2f4..7f368e90a3 100644 --- a/apps/web/modules/auth/verify-view.tsx +++ b/apps/web/modules/auth/verify-view.tsx @@ -2,26 +2,20 @@ import { motion } from "framer-motion"; import { signIn } from "next-auth/react"; -import Head from "next/head"; import { usePathname, useRouter } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import z from "zod"; import { classNames } from "@calcom/lib"; -import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants"; +import { WEBAPP_URL } from "@calcom/lib/constants"; import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery"; import { trpc } from "@calcom/trpc/react"; -import type { inferSSRProps } from "@calcom/types/inferSSRProps"; import { Button, showToast } from "@calcom/ui"; import { Icon } from "@calcom/ui"; import Loader from "@components/Loader"; -import type { getServerSideProps } from "@server/lib/auth/verify/getServerSideProps"; - -export type PageProps = inferSSRProps; - async function sendVerificationLogin(email: string, username: string) { await signIn("email", { email: email.toLowerCase(), @@ -117,7 +111,7 @@ const MailOpenIcon = () => ( ); -export default function Verify(props: PageProps) { +export default function Verify({ EMAIL_FROM }: { EMAIL_FROM?: string }) { const searchParams = useCompatSearchParams(); const pathname = usePathname(); const router = useRouter(); @@ -176,17 +170,6 @@ export default function Verify(props: PageProps) { return (
- - - {/* @note: Ternary can look ugly ant his might be extracted later but I think at 3 it's not yet worth - it or too hard to read. */} - {hasPaymentFailed - ? "Your payment failed" - : sessionId - ? "Payment successful!" - : `Verify your email | ${APP_NAME}`} - -
{hasPaymentFailed ? : sessionId ? : } @@ -209,8 +192,8 @@ export default function Verify(props: PageProps) {