Skip to content

Commit

Permalink
FEAT: ORV2-1961 redirect to suspended route if suspended (#1226)
Browse files Browse the repository at this point in the history
Co-authored-by: Krishnan Subramanian <[email protected]>
  • Loading branch information
erikataot and krishnan-aot authored Feb 29, 2024
1 parent 110cf1b commit 6e1a75a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 2 deletions.
8 changes: 8 additions & 0 deletions frontend/src/common/authentication/LoginRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const navigateBCeID = (
): string | undefined => {
const { associatedCompanies, pendingCompanies, migratedClient, user } =
userContextData;

const isAssociatedSuspended = associatedCompanies?.find((company) => company?.isSuspended);
const isPendingSuspended = pendingCompanies?.find((company) => company?.isSuspended);

// If the user does not exist
if (!user?.userGUID) {
// The user is in pending companies => Redirect them to User Info Page.
Expand All @@ -49,6 +53,10 @@ const navigateBCeID = (
return ERROR_ROUTES.UNAUTHORIZED;
}
}
// The user exists but either the associated company or pending company is suspended
else if (isAssociatedSuspended || isPendingSuspended) {
return ERROR_ROUTES.SUSPENDED;
}
// The user and company exist
else if (associatedCompanies?.length) {
return APPLICATIONS_ROUTES.BASE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export const BCeIDAuthWall = ({
user: userFromToken,
} = useAuth();

const { userRoles, companyId, isNewBCeIDUser } = useContext(OnRouteBCContext);

const { userRoles, companyId, isNewBCeIDUser } =
useContext(OnRouteBCContext);
const userIDP = userFromToken?.profile?.identity_provider as string;

const location = useLocation();
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/common/authentication/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export type CompanyMetadata = {
legalName: string;
companyGUID?: string;
alternateName?: string;
isSuspended?: boolean;
email?: string;
};

/**
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/common/pages/CompanySuspended.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ErrorPage } from "../components/error/ErrorPage";
import { PPC_EMAIL, TOLL_FREE_NUMBER } from "../constants/constants";

export const CompanySuspended = () => {
return (
<ErrorPage
errorTitle="Company suspended"
msgNode={
<>
For further assistance please contact the Provincial Permit
Centre at{" "}
<span>
<strong>Toll-free: {TOLL_FREE_NUMBER}</strong>
</span>{" "}
or{" "}
<span>
<strong>Email: {PPC_EMAIL}</strong>
</span>
</>
}
/>
);
};
5 changes: 5 additions & 0 deletions frontend/src/routes/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ import { CreateProfileWizard } from "../features/wizard/CreateProfileWizard";
import { UserInfoWizard } from "../features/wizard/UserInfoWizard";
import * as routes from "./constants";
import { IDIRCreateCompany } from "../features/idir/company/IDIRCreateCompany";
import { CompanySuspended } from "../common/pages/CompanySuspended";

export const AppRoutes = () => {
return (
<Routes>
{/* Home and Error Routes */}
{/* Home and Error routes do no have any constraints. */}
<Route path={routes.HOME} element={<InitialLandingPage />} />
<Route
path={routes.ERROR_ROUTES.SUSPENDED}
element={<CompanySuspended />}
/>
<Route
path={routes.ERROR_ROUTES.UNAUTHORIZED}
element={<UniversalUnauthorized />}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/routes/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DYNAMIC_ROUTE_URI = (
export const HOME = "/";

export const ERROR_ROUTES = {
SUSPENDED: "/suspended",
UNAUTHORIZED: "/unauthorized",
UNEXPECTED: "/unexpected-error",
};
Expand Down

0 comments on commit 6e1a75a

Please sign in to comment.