From 2f8bf518c8f32eb69f1c2e1a5437c492962655e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kope=C4=8Dek?= Date: Fri, 23 Aug 2024 10:16:31 +0200 Subject: [PATCH] feat: user not enabled page (#68) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martin Kopeček --- studio/app/user-not-enabled/page.tsx | 27 +++++++++++++++++++++++++++ studio/core/utils/withUserEnabled.tsx | 6 ++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 studio/app/user-not-enabled/page.tsx diff --git a/studio/app/user-not-enabled/page.tsx b/studio/app/user-not-enabled/page.tsx new file mode 100644 index 00000000..1683ad22 --- /dev/null +++ b/studio/app/user-not-enabled/page.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { Grid, Heading, View } from "@adobe/react-spectrum"; +import { withPageAuthRequired } from "@auth0/nextjs-auth0/client"; + +function UserNotEnabledPage() { + return ( + + + User Not Enabled + +

+ Your account has not been enabled. Please contact an administrator at{" "} + vojta@stdio.cz +

+
+
+ ); +} + +export default withPageAuthRequired(UserNotEnabledPage); diff --git a/studio/core/utils/withUserEnabled.tsx b/studio/core/utils/withUserEnabled.tsx index 9ce2b771..0fdbc9f4 100644 --- a/studio/core/utils/withUserEnabled.tsx +++ b/studio/core/utils/withUserEnabled.tsx @@ -3,7 +3,9 @@ import { hasAccess } from "@features/auth/hasAccess"; import { redirect } from "next/navigation"; import { useEffect } from "react"; -export const withUserEnabled = (WrappedComponent: React.FC) => { +export const withUserEnabled = ( + WrappedComponent: React.FC, +) => { // eslint-disable-next-line react/display-name return (props: T) => { const { data: enabled } = useQuery({ @@ -12,7 +14,7 @@ export const withUserEnabled = (WrappedComponent: React.FC) => }); useEffect(() => { - if (enabled === false) redirect("/"); + if (enabled === false) redirect("/user-not-enabled"); }, [enabled]); if (!enabled) return null;