Skip to content

Scheduling infrastructure for absolutely everyone.

chore: migrate /auth/forgot-password pages (#18945)

Benny Jooe23ab02c2353
diff --git a/.env.example b/.env.example
index f0633dd3059..ce124f96618 100644
--- a/.env.example
+++ b/.env.example
@@ -359,12 +359,6 @@ AB_TEST_BUCKET_PROBABILITY=50
APP_ROUTER_APPS_SLUG_SETUP_ENABLED=0
APP_ROUTER_APPS_ENABLED=0
APP_ROUTER_TEAM_ENABLED=0
-APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED=0
-APP_ROUTER_AUTH_LOGIN_ENABLED=0
-APP_ROUTER_AUTH_LOGOUT_ENABLED=0
-APP_ROUTER_AUTH_SAML_ENABLED=0
-APP_ROUTER_AUTH_PLATFORM_ENABLED=0
-APP_ROUTER_AUTH_OAUTH2_ENABLED=0
# disable setry server source maps
SENTRY_DISABLE_SERVER_WEBPACK_PLUGIN=1
diff --git a/apps/web/abTest/middlewareFactory.ts b/apps/web/abTest/middlewareFactory.ts
index f375ea6a921..dc06d17ad58 100644
--- a/apps/web/abTest/middlewareFactory.ts
+++ b/apps/web/abTest/middlewareFactory.ts
@@ -6,12 +6,6 @@ import { FUTURE_ROUTES_ENABLED_COOKIE_NAME, FUTURE_ROUTES_OVERRIDE_COOKIE_NAME }
const ROUTES: [URLPattern, boolean][] = [
["/apps/:slug/setup", process.env.APP_ROUTER_APPS_SLUG_SETUP_ENABLED === "1"] as const,
- ["/auth/forgot-password/:path*", process.env.APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED === "1"] as const,
- ["/auth/login", process.env.APP_ROUTER_AUTH_LOGIN_ENABLED === "1"] as const,
- ["/auth/logout", process.env.APP_ROUTER_AUTH_LOGOUT_ENABLED === "1"] as const,
- ["/auth/saml-idp", process.env.APP_ROUTER_AUTH_SAML_ENABLED === "1"] as const,
- ["/auth/platform/:path*", process.env.APP_ROUTER_AUTH_PLATFORM_ENABLED === "1"] as const,
- ["/auth/oauth2/:path*", process.env.APP_ROUTER_AUTH_OAUTH2_ENABLED === "1"] as const,
["/team", process.env.APP_ROUTER_TEAM_ENABLED === "1"] as const,
].map(([pathname, enabled]) => [
new URLPattern({
diff --git a/apps/web/app/(use-page-wrapper)/auth/forgot-password/[id]/page.tsx b/apps/web/app/(use-page-wrapper)/auth/forgot-password/[id]/page.tsx
new file mode 100644
index 00000000000..4810f917a44
--- /dev/null
+++ b/apps/web/app/(use-page-wrapper)/auth/forgot-password/[id]/page.tsx
@@ -0,0 +1,28 @@
+import { withAppDirSsr } from "app/WithAppDirSsr";
+import type { PageProps as ServerPageProps } from "app/_types";
+import { _generateMetadata } from "app/_utils";
+import { cookies, headers } from "next/headers";
+
+import { buildLegacyCtx } from "@lib/buildLegacyCtx";
+
+import { getServerSideProps } from "@server/lib/auth/forgot-password/[id]/getServerSideProps";
+
+import type { PageProps as ClientPageProps } from "~/auth/forgot-password/[id]/forgot-password-single-view";
+import SetNewUserPassword from "~/auth/forgot-password/[id]/forgot-password-single-view";
+
+export const generateMetadata = async () => {
+ return await _generateMetadata(
+ (t) => t("reset_password"),
+ (t) => t("change_your_password")
+ );
+};
+
+const getData = withAppDirSsr<ClientPageProps>(getServerSideProps);
+const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
+ const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
+ const props = await getData(context);
+
+ return <SetNewUserPassword {...props} />;
+};
+
+export default ServerPage;
diff --git a/apps/web/app/(use-page-wrapper)/auth/forgot-password/page.tsx b/apps/web/app/(use-page-wrapper)/auth/forgot-password/page.tsx
new file mode 100644
index 00000000000..0b656a734f0
--- /dev/null
+++ b/apps/web/app/(use-page-wrapper)/auth/forgot-password/page.tsx
@@ -0,0 +1,33 @@
+import type { PageProps as ServerPageProps } from "app/_types";
+import { _generateMetadata } from "app/_utils";
+import { getCsrfToken } from "next-auth/react";
+import { cookies, headers } from "next/headers";
+import { redirect } from "next/navigation";
+
+import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
+
+import { buildLegacyCtx } from "@lib/buildLegacyCtx";
+
+import ForgotPassword from "~/auth/forgot-password/forgot-password-view";
+
+export const generateMetadata = async () => {
+ return await _generateMetadata(
+ (t) => t("forgot_password"),
+ (t) => t("request_password_reset")
+ );
+};
+
+const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
+ const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
+ const session = await getServerSession({ req: context.req });
+
+ if (session) {
+ redirect("/");
+ }
+
+ const csrfToken = await getCsrfToken(context);
+
+ return <ForgotPassword csrfToken={csrfToken} />;
+};
+
+export default ServerPage;
diff --git a/apps/web/app/future/auth/forgot-password/[id]/page.tsx b/apps/web/app/future/auth/forgot-password/[id]/page.tsx
deleted file mode 100644
index 3fe21ff6858..00000000000
--- a/apps/web/app/future/auth/forgot-password/[id]/page.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-
-import { getServerSideProps } from "@server/lib/auth/forgot-password/[id]/getServerSideProps";
-
-import type { PageProps } from "~/auth/forgot-password/[id]/forgot-password-single-view";
-import SetNewUserPassword from "~/auth/forgot-password/[id]/forgot-password-single-view";
-
-export const generateMetadata = async () => {
- return await _generateMetadata(
- (t) => t("reset_password"),
- (t) => t("change_your_password")
- );
-};
-
-export default WithLayout({
- getLayout: null,
- Page: SetNewUserPassword,
- getData: withAppDirSsr<PageProps>(getServerSideProps),
-})<"P">;
diff --git a/apps/web/app/future/auth/forgot-password/page.tsx b/apps/web/app/future/auth/forgot-password/page.tsx
deleted file mode 100644
index b66348f5e25..00000000000
--- a/apps/web/app/future/auth/forgot-password/page.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { withAppDirSsr } from "app/WithAppDirSsr";
-import { _generateMetadata } from "app/_utils";
-import { WithLayout } from "app/layoutHOC";
-
-import { getServerSidePropsAppDir } from "@server/lib/auth/forgot-password/getServerSideProps";
-
-import type { PageProps } from "~/auth/forgot-password/forgot-password-view";
-import ForgotPassword from "~/auth/forgot-password/forgot-password-view";
-
-export const generateMetadata = async () => {
- return await _generateMetadata(
- (t) => t("forgot_password"),
- (t) => t("request_password_reset")
- );
-};
-
-export default WithLayout({
- getLayout: null,
- Page: ForgotPassword,
- getData: withAppDirSsr<PageProps>(getServerSidePropsAppDir),
-})<"P">;
diff --git a/apps/web/modules/auth/forgot-password/forgot-password-view.tsx b/apps/web/modules/auth/forgot-password/forgot-password-view.tsx
index d8587cd1145..c0342088d49 100644
--- a/apps/web/modules/auth/forgot-password/forgot-password-view.tsx
+++ b/apps/web/modules/auth/forgot-password/forgot-password-view.tsx
@@ -9,13 +9,11 @@ import React from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, EmailField } from "@calcom/ui";
-import { type inferSSRProps } from "@lib/types/inferSSRProps";
-
import AuthContainer from "@components/ui/AuthContainer";
-import type { getServerSideProps } from "@server/lib/auth/forgot-password/getServerSideProps";
-
-export type PageProps = inferSSRProps<typeof getServerSideProps>;
+export type PageProps = {
+ csrfToken?: string;
+};
export default function ForgotPassword(props: PageProps) {
const csrfToken = "csrfToken" in props ? (props.csrfToken as string) : undefined;
diff --git a/apps/web/pages/auth/forgot-password/[id].tsx b/apps/web/pages/auth/forgot-password/[id].tsx
deleted file mode 100644
index 07861ce4c69..00000000000
--- a/apps/web/pages/auth/forgot-password/[id].tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import PageWrapper from "@components/PageWrapper";
-
-import type { PageProps } from "~/auth/forgot-password/[id]/forgot-password-single-view";
-import ForgotPassword from "~/auth/forgot-password/[id]/forgot-password-single-view";
-
-const Page = (props: PageProps) => <ForgotPassword {...props} />;
-Page.PageWrapper = PageWrapper;
-
-export default Page;
-
-export { getServerSideProps } from "@server/lib/auth/forgot-password/[id]/getServerSideProps";
diff --git a/apps/web/pages/auth/forgot-password/index.tsx b/apps/web/pages/auth/forgot-password/index.tsx
deleted file mode 100644
index 56bbf7b1491..00000000000
--- a/apps/web/pages/auth/forgot-password/index.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import PageWrapper from "@components/PageWrapper";
-
-import type { PageProps } from "~/auth/forgot-password/forgot-password-view";
-import ForgotPassword from "~/auth/forgot-password/forgot-password-view";
-
-const Page = (props: PageProps) => <ForgotPassword {...props} />;
-Page.PageWrapper = PageWrapper;
-
-export default Page;
-
-export { getServerSideProps } from "@server/lib/auth/forgot-password/getServerSideProps";
diff --git a/apps/web/scripts/vercel-app-router-deploy.sh b/apps/web/scripts/vercel-app-router-deploy.sh
index 014536edac2..b9f36a543df 100755
--- a/apps/web/scripts/vercel-app-router-deploy.sh
+++ b/apps/web/scripts/vercel-app-router-deploy.sh
@@ -7,12 +7,6 @@ checkRoute () {
# These conditionals are used to remove directories from the build that are not needed in production
# This is to reduce the size of the build and prevent OOM errors
checkRoute "$APP_ROUTER_APPS_SLUG_SETUP_ENABLED" app/future/apps/\[slug\]/setup
-checkRoute "$APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED" app/future/auth/forgot-password
-checkRoute "$APP_ROUTER_AUTH_LOGIN_ENABLED" app/future/auth/login
-checkRoute "$APP_ROUTER_AUTH_LOGOUT_ENABLED" app/future/auth/logout
-checkRoute "$APP_ROUTER_AUTH_SAML_ENABLED" app/future/auth/saml-idp
-checkRoute "$APP_ROUTER_AUTH_PLATFORM_ENABLED" app/future/auth/platform
-checkRoute "$APP_ROUTER_AUTH_OAUTH2_ENABLED" app/future/auth/oauth2
checkRoute "$APP_ROUTER_TEAM_ENABLED" app/future/team
# These are routes that don't have and environment variable to enable or disable them
diff --git a/apps/web/server/lib/auth/forgot-password/getServerSideProps.tsx b/apps/web/server/lib/auth/forgot-password/getServerSideProps.tsx
deleted file mode 100644
index 919fd8c03e8..00000000000
--- a/apps/web/server/lib/auth/forgot-password/getServerSideProps.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import type { GetServerSidePropsContext } from "next";
-import { getCsrfToken } from "next-auth/react";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
-
-import { getLocale } from "@calcom/features/auth/lib/getLocale";
-import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
-
-export async function getServerSideProps(context: GetServerSidePropsContext) {
- const { req, res } = context;
-
- const session = await getServerSession({ req });
-
- if (session) {
- res.writeHead(302, { Location: "/" });
- res.end();
- return { props: {} };
- }
- const locale = await getLocale(context.req);
-
- return {
- props: {
- csrfToken: await getCsrfToken(context),
- ...(await serverSideTranslations(locale, ["common"])),
- },
- };
-}
-
-export async function getServerSidePropsAppDir(context: GetServerSidePropsContext) {
- const { req } = context;
-
- const session = await getServerSession({ req });
-
- if (session) {
- const redirect = await import("next/navigation").then((mod) => mod.redirect);
- redirect("/");
- return { props: {} };
- }
- const locale = await getLocale(context.req);
-
- return {
- props: {
- csrfToken: await getCsrfToken(context),
- ...(await serverSideTranslations(locale, ["common"])),
- },
- };
-}
diff --git a/turbo.json b/turbo.json
index 9da10623fea..1970f44a183 100644
--- a/turbo.json
+++ b/turbo.json
@@ -241,12 +241,6 @@
"ANALYZE",
"API_KEY_PREFIX",
"APP_ROUTER_APPS_SLUG_SETUP_ENABLED",
- "APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED",
- "APP_ROUTER_AUTH_LOGIN_ENABLED",
- "APP_ROUTER_AUTH_LOGOUT_ENABLED",
- "APP_ROUTER_AUTH_SAML_ENABLED",
- "APP_ROUTER_AUTH_PLATFORM_ENABLED",
- "APP_ROUTER_AUTH_OAUTH2_ENABLED",
"APP_ROUTER_TEAM_ENABLED",
"APP_USER_NAME",
"BASECAMP3_CLIENT_ID",