MSP-3107 update permissions logic
This commit is contained in:
1 parent
90e9485f19
commit
d63afbfcd0
4 files changed
+17
-9
No files matched your search
@@ -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 <Navigate to={routePaths.login} replace />
|
||||
}
|
||||
|
||||
if ( location.pathname !=='/' && !hasPermission(PermissionKeys.read)) {
|
||||
return <Navigate to={routePaths.home} replace />
|
||||
}
|
||||
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user