Skip to content

Commit

Permalink
feat: user not enabled page (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Kopeček <martin.kopecek@smallhill.cz>
  • Loading branch information
SmallhillCZ and SmallhillCZ authored Aug 23, 2024
1 parent 706d418 commit 2f8bf51
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
27 changes: 27 additions & 0 deletions studio/app/user-not-enabled/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use client";

import { Grid, Heading, View } from "@adobe/react-spectrum";
import { withPageAuthRequired } from "@auth0/nextjs-auth0/client";

function UserNotEnabledPage() {
return (
<Grid
width="100%"
height="100%"
gap="size-100"
justifyContent="start"
alignItems="start"
>
<View marginX="size-100">
<Heading level={1}>User Not Enabled</Heading>

<p>
Your account has not been enabled. Please contact an administrator at{" "}
<a href="mailto:vojta@stdio.cz">vojta@stdio.cz</a>
</p>
</View>
</Grid>
);
}

export default withPageAuthRequired(UserNotEnabledPage);
6 changes: 4 additions & 2 deletions studio/core/utils/withUserEnabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { hasAccess } from "@features/auth/hasAccess";
import { redirect } from "next/navigation";
import { useEffect } from "react";

export const withUserEnabled = <T extends {}>(WrappedComponent: React.FC<T>) => {
export const withUserEnabled = <T extends {}>(
WrappedComponent: React.FC<T>,
) => {
// eslint-disable-next-line react/display-name
return (props: T) => {
const { data: enabled } = useQuery({
Expand All @@ -12,7 +14,7 @@ export const withUserEnabled = <T extends {}>(WrappedComponent: React.FC<T>) =>
});

useEffect(() => {
if (enabled === false) redirect("/");
if (enabled === false) redirect("/user-not-enabled");
}, [enabled]);

if (!enabled) return null;
Expand Down

0 comments on commit 2f8bf51

Please sign in to comment.