visuddhinanda 2 лет назад
Родитель
Сommit
68df1e12cb
1 измененных файлов с 15 добавлено и 2 удалено
  1. 15 2
      dashboard/src/pages/admin/index.tsx

+ 15 - 2
dashboard/src/pages/admin/index.tsx

@@ -1,15 +1,28 @@
-import { Layout } from "antd";
+import { Layout, Result } from "antd";
 import { Outlet } from "react-router-dom";
 import LeftSider from "../../components/admin/LeftSider";
 import HeadBar from "../../components/studio/HeadBar";
+import { useAppSelector } from "../../hooks";
+import { currentUser } from "../../reducers/current-user";
 
 const Widget = () => {
+  const user = useAppSelector(currentUser);
+
   return (
     <div>
       <HeadBar />
       <Layout>
         <LeftSider />
-        <Outlet />
+        {user?.roles?.includes("root") ||
+        user?.roles?.includes("administrator") ? (
+          <Outlet />
+        ) : (
+          <Result
+            status="403"
+            title="403"
+            subTitle="Sorry, you are not authorized to access this page."
+          />
+        )}
       </Layout>
     </div>
   );