Skip to content

Commit e23ab02

Browse files
authored
chore: migrate /auth/forgot-password pages (calcom#18945)
1 parent 8205431 commit e23ab02

File tree

12 files changed

+64
-139
lines changed

12 files changed

+64
-139
lines changed

.env.example

-6
Original file line numberDiff line numberDiff line change
@@ -359,12 +359,6 @@ AB_TEST_BUCKET_PROBABILITY=50
359359
APP_ROUTER_APPS_SLUG_SETUP_ENABLED=0
360360
APP_ROUTER_APPS_ENABLED=0
361361
APP_ROUTER_TEAM_ENABLED=0
362-
APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED=0
363-
APP_ROUTER_AUTH_LOGIN_ENABLED=0
364-
APP_ROUTER_AUTH_LOGOUT_ENABLED=0
365-
APP_ROUTER_AUTH_SAML_ENABLED=0
366-
APP_ROUTER_AUTH_PLATFORM_ENABLED=0
367-
APP_ROUTER_AUTH_OAUTH2_ENABLED=0
368362

369363
# disable setry server source maps
370364
SENTRY_DISABLE_SERVER_WEBPACK_PLUGIN=1

apps/web/abTest/middlewareFactory.ts

-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import { FUTURE_ROUTES_ENABLED_COOKIE_NAME, FUTURE_ROUTES_OVERRIDE_COOKIE_NAME }
66

77
const ROUTES: [URLPattern, boolean][] = [
88
["/apps/:slug/setup", process.env.APP_ROUTER_APPS_SLUG_SETUP_ENABLED === "1"] as const,
9-
["/auth/forgot-password/:path*", process.env.APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED === "1"] as const,
10-
["/auth/login", process.env.APP_ROUTER_AUTH_LOGIN_ENABLED === "1"] as const,
11-
["/auth/logout", process.env.APP_ROUTER_AUTH_LOGOUT_ENABLED === "1"] as const,
12-
["/auth/saml-idp", process.env.APP_ROUTER_AUTH_SAML_ENABLED === "1"] as const,
13-
["/auth/platform/:path*", process.env.APP_ROUTER_AUTH_PLATFORM_ENABLED === "1"] as const,
14-
["/auth/oauth2/:path*", process.env.APP_ROUTER_AUTH_OAUTH2_ENABLED === "1"] as const,
159
["/team", process.env.APP_ROUTER_TEAM_ENABLED === "1"] as const,
1610
].map(([pathname, enabled]) => [
1711
new URLPattern({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { withAppDirSsr } from "app/WithAppDirSsr";
2+
import type { PageProps as ServerPageProps } from "app/_types";
3+
import { _generateMetadata } from "app/_utils";
4+
import { cookies, headers } from "next/headers";
5+
6+
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
7+
8+
import { getServerSideProps } from "@server/lib/auth/forgot-password/[id]/getServerSideProps";
9+
10+
import type { PageProps as ClientPageProps } from "~/auth/forgot-password/[id]/forgot-password-single-view";
11+
import SetNewUserPassword from "~/auth/forgot-password/[id]/forgot-password-single-view";
12+
13+
export const generateMetadata = async () => {
14+
return await _generateMetadata(
15+
(t) => t("reset_password"),
16+
(t) => t("change_your_password")
17+
);
18+
};
19+
20+
const getData = withAppDirSsr<ClientPageProps>(getServerSideProps);
21+
const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
22+
const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
23+
const props = await getData(context);
24+
25+
return <SetNewUserPassword {...props} />;
26+
};
27+
28+
export default ServerPage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { PageProps as ServerPageProps } from "app/_types";
2+
import { _generateMetadata } from "app/_utils";
3+
import { getCsrfToken } from "next-auth/react";
4+
import { cookies, headers } from "next/headers";
5+
import { redirect } from "next/navigation";
6+
7+
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
8+
9+
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
10+
11+
import ForgotPassword from "~/auth/forgot-password/forgot-password-view";
12+
13+
export const generateMetadata = async () => {
14+
return await _generateMetadata(
15+
(t) => t("forgot_password"),
16+
(t) => t("request_password_reset")
17+
);
18+
};
19+
20+
const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
21+
const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
22+
const session = await getServerSession({ req: context.req });
23+
24+
if (session) {
25+
redirect("/");
26+
}
27+
28+
const csrfToken = await getCsrfToken(context);
29+
30+
return <ForgotPassword csrfToken={csrfToken} />;
31+
};
32+
33+
export default ServerPage;

apps/web/app/future/auth/forgot-password/[id]/page.tsx

-21
This file was deleted.

apps/web/app/future/auth/forgot-password/page.tsx

-21
This file was deleted.

apps/web/modules/auth/forgot-password/forgot-password-view.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ import React from "react";
99
import { useLocale } from "@calcom/lib/hooks/useLocale";
1010
import { Button, EmailField } from "@calcom/ui";
1111

12-
import { type inferSSRProps } from "@lib/types/inferSSRProps";
13-
1412
import AuthContainer from "@components/ui/AuthContainer";
1513

16-
import type { getServerSideProps } from "@server/lib/auth/forgot-password/getServerSideProps";
17-
18-
export type PageProps = inferSSRProps<typeof getServerSideProps>;
14+
export type PageProps = {
15+
csrfToken?: string;
16+
};
1917

2018
export default function ForgotPassword(props: PageProps) {
2119
const csrfToken = "csrfToken" in props ? (props.csrfToken as string) : undefined;

apps/web/pages/auth/forgot-password/[id].tsx

-11
This file was deleted.

apps/web/pages/auth/forgot-password/index.tsx

-11
This file was deleted.

apps/web/scripts/vercel-app-router-deploy.sh

-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ checkRoute () {
77
# These conditionals are used to remove directories from the build that are not needed in production
88
# This is to reduce the size of the build and prevent OOM errors
99
checkRoute "$APP_ROUTER_APPS_SLUG_SETUP_ENABLED" app/future/apps/\[slug\]/setup
10-
checkRoute "$APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED" app/future/auth/forgot-password
11-
checkRoute "$APP_ROUTER_AUTH_LOGIN_ENABLED" app/future/auth/login
12-
checkRoute "$APP_ROUTER_AUTH_LOGOUT_ENABLED" app/future/auth/logout
13-
checkRoute "$APP_ROUTER_AUTH_SAML_ENABLED" app/future/auth/saml-idp
14-
checkRoute "$APP_ROUTER_AUTH_PLATFORM_ENABLED" app/future/auth/platform
15-
checkRoute "$APP_ROUTER_AUTH_OAUTH2_ENABLED" app/future/auth/oauth2
1610
checkRoute "$APP_ROUTER_TEAM_ENABLED" app/future/team
1711

1812
# These are routes that don't have and environment variable to enable or disable them

apps/web/server/lib/auth/forgot-password/getServerSideProps.tsx

-46
This file was deleted.

turbo.json

-6
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@
241241
"ANALYZE",
242242
"API_KEY_PREFIX",
243243
"APP_ROUTER_APPS_SLUG_SETUP_ENABLED",
244-
"APP_ROUTER_AUTH_FORGOT_PASSWORD_ENABLED",
245-
"APP_ROUTER_AUTH_LOGIN_ENABLED",
246-
"APP_ROUTER_AUTH_LOGOUT_ENABLED",
247-
"APP_ROUTER_AUTH_SAML_ENABLED",
248-
"APP_ROUTER_AUTH_PLATFORM_ENABLED",
249-
"APP_ROUTER_AUTH_OAUTH2_ENABLED",
250244
"APP_ROUTER_TEAM_ENABLED",
251245
"APP_USER_NAME",
252246
"BASECAMP3_CLIENT_ID",

0 commit comments

Comments
 (0)