mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 01:26:43 +00:00
misc: addressed review comment
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createContext, ReactNode, useContext, useMemo } from "react";
|
import { createContext, ReactNode, useContext, useEffect, useMemo } from "react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
@@ -32,22 +32,27 @@ export const WorkspaceProvider = ({ children }: Props): JSX.Element => {
|
|||||||
};
|
};
|
||||||
}, [ws, workspaceId, isLoading]);
|
}, [ws, workspaceId, isLoading]);
|
||||||
|
|
||||||
// handle redirects to project-specific routes
|
const shouldTriggerNoProjectAccess =
|
||||||
if (
|
|
||||||
!value.isLoading &&
|
!value.isLoading &&
|
||||||
!value.currentWorkspace &&
|
!value.currentWorkspace &&
|
||||||
router.pathname.startsWith("/project") &&
|
router.pathname.startsWith("/project") &&
|
||||||
workspaceId
|
workspaceId;
|
||||||
) {
|
|
||||||
createNotification({
|
|
||||||
text: "You are not a member of this project.",
|
|
||||||
type: "info"
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
// handle redirects for project-specific routes
|
||||||
router.push("/");
|
useEffect(() => {
|
||||||
}, 5000);
|
if (shouldTriggerNoProjectAccess) {
|
||||||
|
createNotification({
|
||||||
|
text: "You are not a member of this project.",
|
||||||
|
type: "info"
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
router.push("/");
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
}, [shouldTriggerNoProjectAccess, router]);
|
||||||
|
|
||||||
|
if (shouldTriggerNoProjectAccess) {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen w-screen items-center justify-center bg-bunker-800 text-primary-50">
|
<div className="flex h-screen w-screen items-center justify-center bg-bunker-800 text-primary-50">
|
||||||
You do not have sufficient access to this project.
|
You do not have sufficient access to this project.
|
||||||
|
|||||||
Reference in New Issue
Block a user