Skip to content

Commit 14413e9

Browse files
feat: add support for redirecting user to signup blocked if not allowed
1 parent 69c06df commit 14413e9

File tree

8 files changed

+66
-13
lines changed

8 files changed

+66
-13
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Card } from "@shared/ui";
2+
import classNames from "classnames/bind";
3+
4+
import style from "./no-access.module.scss";
5+
const cx = classNames.bind(style);
6+
7+
type NoAccessProps = {
8+
headerText: string;
9+
descriptionComponent: React.ReactNode;
10+
useDangerAccent?: boolean;
11+
};
12+
13+
export const NoAccess: React.FC<NoAccessProps> = ({ headerText, descriptionComponent, useDangerAccent = false }) => {
14+
return (
15+
<Card className={cx("noAccessMessageContainer")}>
16+
<div className={cx("header")}>{headerText}</div>
17+
<div className={cx("messageContainer", { danger: useDangerAccent })}>{descriptionComponent}</div>
18+
</Card>
19+
);
20+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { NoAccess } from "./NoAccess";
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.awaitingApprovalMessageContainer {
1+
.noAccessMessageContainer {
22
.header {
33
font-weight: 700;
44
font-size: 28px;
@@ -26,5 +26,13 @@
2626
line-height: 20px;
2727
color: var(--neutral-color-neutral-11);
2828
}
29+
30+
&.danger {
31+
border-color: var(--semantic-colors-error-6);
32+
33+
b {
34+
color: var(--semantic-colors-error-9);
35+
}
36+
}
2937
}
3038
}
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
import { Card } from "@shared/ui";
2-
import classNames from "classnames/bind";
3-
1+
import { NoAccess } from "../../components/no-access/NoAccess";
42
import { usePluginContext } from "../../plugin";
53

6-
import style from "./awaiting-approval.module.scss";
7-
const cx = classNames.bind(style);
8-
94
export const AwaitingApproval = () => {
105
const { t } = usePluginContext();
116

127
return (
13-
<Card className={cx("awaitingApprovalMessageContainer")}>
14-
<div className={cx("header")}>{t("PL_TE_JOIN_TENANT_AWAITING_APPROVAL_HEADER")}</div>
15-
<div className={cx("messageContainer")}>
8+
<NoAccess
9+
headerText={t("PL_TE_JOIN_TENANT_AWAITING_APPROVAL_HEADER")}
10+
descriptionComponent={
1611
<div>
1712
{t("PL_TE_JOIN_TENANT_AWAITING_APPROVAL_MESSAGE")}{" "}
1813
<b>{t("PL_TE_JOIN_TENANT_AWAITING_APPROVAL_MESSAGE_HIGHLIGHT")}</b>
1914
</div>
20-
</div>
21-
</Card>
15+
}
16+
/>
2217
);
2318
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { SignUpBlocked } from "./signup-blocked";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NoAccess } from "../../components/no-access/NoAccess";
2+
import { usePluginContext } from "../../plugin";
3+
4+
export const SignUpBlocked = () => {
5+
const { t } = usePluginContext();
6+
7+
return (
8+
<NoAccess
9+
headerText={t("PL_TE_JOIN_TENANT_AWAITING_APPROVAL_HEADER")}
10+
descriptionComponent={
11+
<div>
12+
<b>{t("PL_TE_SIGN_UP_BLOCKED_MESSAGE_HIGHLIGHT")}</b> <b>{t("PL_TE_SIGN_UP_BLOCKED_MESSAGE_SUFFIX")}</b>
13+
</div>
14+
}
15+
useDangerAccent
16+
/>
17+
);
18+
};

packages/tenant-enrollment-react/src/plugin.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getApi } from "./api";
1414
import { PLUGIN_ID, API_PATH } from "./constants";
1515
import { enableDebugLogs, logDebugMessage } from "./logger";
1616
import { AwaitingApproval } from "./pages/awaiting-approval";
17+
import { SignUpBlocked } from "./pages/blocked";
1718
import { defaultTranslationsTenantEnrollment } from "./translations";
1819
import { SuperTokensPluginTenantEnrollmentPluginConfig, TranslationKeys } from "./types";
1920

@@ -70,6 +71,10 @@ export const init = createPluginInitFunction<
7071
path: "/awaiting-approval",
7172
handler: () => AwaitingApproval.call(null),
7273
},
74+
{
75+
path: "/signup-blocked",
76+
handler: () => SignUpBlocked.call(null),
77+
},
7378
],
7479
};
7580
},
@@ -95,7 +100,8 @@ export const init = createPluginInitFunction<
95100
// Update the message before re-throwing the error
96101
error.message = "Not allowed to signup to tenant";
97102

98-
// TODO: Redirect the user to not allowed to signup view
103+
// Redirect the user to not allowed to signup view
104+
window.location.assign("/signup-blocked");
99105
}
100106
}
101107

packages/tenant-enrollment-react/src/translations.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ export const defaultTranslationsTenantEnrollment = {
44
PL_TE_JOIN_TENANT_AWAITING_APPROVAL_MESSAGE:
55
"It is essential to obtain the tenant administrator's approval before proceeding with the",
66
PL_TE_JOIN_TENANT_AWAITING_APPROVAL_MESSAGE_HIGHLIGHT: "tenant joining process",
7+
PL_TE_SIGN_UP_BLOCKED_HEADER: "Signing up to the tenant is disabled",
8+
PL_TE_SIGN_UP_BLOCKED_MESSAGE_HIGHLIGHT: "Signing up to this tenant is currently blocked.",
9+
PL_TE_SIGN_UP_BLOCKED_MESSAGE_SUFFIX:
10+
"If you think this is a mistake, please reach out to tenant administrators or request an invitation to join the tenant.",
711
},
812
} as const;

0 commit comments

Comments
 (0)