diff --git a/src/components/AdminPermission/index.tsx b/src/components/AdminPermission/index.tsx
index 8fe29b8..310f505 100644
--- a/src/components/AdminPermission/index.tsx
+++ b/src/components/AdminPermission/index.tsx
@@ -7,7 +7,7 @@ import { PermissionKeys } from '@type/roles.type.ts'
const AdminPermission = ({ children }: PropsWithChildren) => {
const { hasPermission } = useRole()
- if (hasPermission(PermissionKeys.admin_view)) {
+ if (hasPermission(PermissionKeys.read)) {
return <>{children}>
}
return null
diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx
index 652a23b..fdffbf5 100644
--- a/src/components/Layout/index.tsx
+++ b/src/components/Layout/index.tsx
@@ -55,19 +55,19 @@ const LayoutComponent = () => {
{
label: 'Доступы приложений',
key: 'appAccess',
- className: hideItem([PermissionKeys.user_view]),
+ className: hideItem([PermissionKeys.read]),
icon:
},
{
label: 'Пользователи и роли',
key: 'sessionManagement',
- className: hideItem([PermissionKeys.user_view]),
+ className: hideItem([PermissionKeys.read]),
icon: ,
children: [
{
label: 'Пользователи',
key: 'users',
- className: hideItem(PermissionKeys.user_view)
+ className: hideItem(PermissionKeys.read)
}
]
}
diff --git a/src/routes/PrivateRoute/index.tsx b/src/routes/PrivateRoute/index.tsx
index 4a2161c..ded5c5a 100644
--- a/src/routes/PrivateRoute/index.tsx
+++ b/src/routes/PrivateRoute/index.tsx
@@ -4,9 +4,16 @@ import { localStorageKeys } from '@constants/localStorageKeys.ts'
import { LocalStorage } from '@utils/localStorageUtils.ts'
+import useRole from '@hooks/useRole.tsx'
+
import { routePaths } from '@routes/routePaths.ts'
+import { PermissionKeys } from '@type/roles.type.ts'
+
+
const PrivateRoute = () => {
+ const { hasPermission } = useRole()
+
const location = useLocation()
const userToken = LocalStorage.get(localStorageKeys.USER_TOKEN)
@@ -15,6 +22,10 @@ const PrivateRoute = () => {
return
}
+ if ( location.pathname !=='/' && !hasPermission(PermissionKeys.read)) {
+ return
+ }
+
return
}
diff --git a/src/type/roles.type.ts b/src/type/roles.type.ts
index fea0891..ce617ac 100644
--- a/src/type/roles.type.ts
+++ b/src/type/roles.type.ts
@@ -4,11 +4,8 @@ export enum RoleKeys {
}
export enum PermissionKeys {
- user_view = 'user_view', // Просмотр списка пользователей
- admin_view = 'admin_view', // роль суперадмина, требуется для интерфейса
- session_view = 'session_view', // Просмотр списка пользовательских сессий
- security_log_view = 'security_log_view', // Просмотр журналов ИБ
- role_view = 'role_view', // Просмотр экрана ролей
+ read = 'read', // Просмотр страниц
+ write = 'write', // Редактирование страниц
}
export type RoleType = {