Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate /auth/error #18730

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ APP_ROUTER_AUTH_LOGIN_ENABLED=0
APP_ROUTER_AUTH_LOGOUT_ENABLED=0
APP_ROUTER_AUTH_NEW_ENABLED=0
APP_ROUTER_AUTH_SAML_ENABLED=0
APP_ROUTER_AUTH_ERROR_ENABLED=0
APP_ROUTER_AUTH_PLATFORM_ENABLED=0
APP_ROUTER_AUTH_OAUTH2_ENABLED=0

Expand Down
1 change: 0 additions & 1 deletion apps/web/abTest/middlewareFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const ROUTES: [URLPattern, boolean][] = [
["/auth/logout", process.env.APP_ROUTER_AUTH_LOGOUT_ENABLED === "1"] as const,
["/auth/new", process.env.APP_ROUTER_AUTH_NEW_ENABLED === "1"] as const,
["/auth/saml-idp", process.env.APP_ROUTER_AUTH_SAML_ENABLED === "1"] as const,
["/auth/error", process.env.APP_ROUTER_AUTH_ERROR_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,
Expand Down
47 changes: 47 additions & 0 deletions apps/web/app/auth/error/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { PageProps } from "app/_types";
import { _generateMetadata, getTranslate } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import Link from "next/link";
import { z } from "zod";

import { Button, Icon } from "@calcom/ui";

import AuthContainer from "@components/ui/AuthContainer";

export const generateMetadata = async () => {
return await _generateMetadata(
(t) => t("error"),
() => ""
);
};

const querySchema = z.object({
error: z.string().optional(),
});

const ServerPage = async ({ searchParams }: PageProps) => {
const t = await getTranslate();
const { error } = querySchema.parse({ error: searchParams?.error || undefined });
const errorMsg = error || t("error_during_login");
return (
<AuthContainer title="" description="" isAppDir={true}>
<div>
<div className="bg-error mx-auto flex h-12 w-12 items-center justify-center rounded-full">
<Icon name="x" className="h-6 w-6 text-red-600" />
</div>
<div className="mt-3 text-center sm:mt-5">
<h3 className="text-emphasis text-lg font-medium leading-6" id="modal-title">
{errorMsg}
</h3>
</div>
</div>
<div className="mt-5 sm:mt-6">
<Link href="/auth/login">
<Button className="flex w-full justify-center">{t("go_back_login")}</Button>
</Link>
</div>
</AuthContainer>
);
};

export default WithLayout({ ServerPage })<"P">;
19 changes: 0 additions & 19 deletions apps/web/app/future/auth/error/page.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion apps/web/components/ui/AuthContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ interface Props {
showLogo?: boolean;
heading?: string;
loading?: boolean;
isAppDir?: boolean;
}

export default function AuthContainer(props: React.PropsWithChildren<Props>) {
return (
<div className="bg-subtle dark:bg-darkgray-50 flex min-h-screen flex-col justify-center py-12 sm:px-6 lg:px-8">
<HeadSeo title={props.title} description={props.description} />
{!props.isAppDir ? <HeadSeo title={props.title} description={props.description} /> : null}
{props.showLogo && <Logo small inline={false} className="mx-auto mb-auto" />}

<div className={classNames(props.showLogo ? "text-center" : "", "sm:mx-auto sm:w-full sm:max-w-md")}>
Expand Down
2 changes: 1 addition & 1 deletion apps/web/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const config = {
"/api/trpc/:path*",
"/login",
"/auth/login",
"/future/auth/login",
"/auth/error",
/**
* Paths required by routingForms.handle
*/
Expand Down
4 changes: 1 addition & 3 deletions apps/web/modules/auth/error/error-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import { Button, Icon } from "@calcom/ui";

import AuthContainer from "@components/ui/AuthContainer";

import type { PageProps } from "@server/lib/auth/error/getStaticProps";

const querySchema = z.object({
error: z.string().optional(),
});

export default function Error(props: PageProps) {
export default function Error() {
const { t } = useLocale();
const searchParams = useSearchParams();
const { error } = querySchema.parse({ error: searchParams?.get("error") || undefined });
Expand Down
11 changes: 0 additions & 11 deletions apps/web/pages/auth/error.tsx

This file was deleted.

1 change: 0 additions & 1 deletion apps/web/scripts/vercel-app-router-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ checkRoute "$APP_ROUTER_AUTH_LOGIN_ENABLED" app/future/auth/login
checkRoute "$APP_ROUTER_AUTH_LOGOUT_ENABLED" app/future/auth/logout
checkRoute "$APP_ROUTER_AUTH_NEW_ENABLED" app/future/auth/new
checkRoute "$APP_ROUTER_AUTH_SAML_ENABLED" app/future/auth/saml-idp
checkRoute "$APP_ROUTER_AUTH_ERROR_ENABLED" app/future/auth/error
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
Expand Down
14 changes: 0 additions & 14 deletions apps/web/server/lib/auth/error/getStaticProps.ts

This file was deleted.

1 change: 0 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@
"APP_ROUTER_AUTH_LOGOUT_ENABLED",
"APP_ROUTER_AUTH_NEW_ENABLED",
"APP_ROUTER_AUTH_SAML_ENABLED",
"APP_ROUTER_AUTH_ERROR_ENABLED",
"APP_ROUTER_AUTH_PLATFORM_ENABLED",
"APP_ROUTER_AUTH_OAUTH2_ENABLED",
"APP_ROUTER_TEAM_ENABLED",
Expand Down
Loading