55
66import { createRouter , createWebHistory , type Router , type RouteRecordRaw } from 'vue-router'
77
8- import { getCurrentUser } from '@nextcloud/auth'
98import { loadState } from '@nextcloud/initial-state'
109import { getRootUrl , generateUrl } from '@nextcloud/router'
1110
@@ -26,29 +25,6 @@ function generateWebBasePath(): string {
2625 } )
2726}
2827
29- type EffectivePolicySummary = {
30- groupCount ?: number
31- userCount ?: number
32- editableByCurrentActor ?: boolean
33- }
34-
35- function canAccessPoliciesRoute ( ) : boolean {
36- if ( getCurrentUser ( ) ?. isAdmin ) {
37- return true
38- }
39-
40- const config = loadState < { can_manage_group_policies ?: boolean } > ( 'libresign' , 'config' , { } )
41- if ( ! config ?. can_manage_group_policies ) {
42- return false
43- }
44-
45- const effectivePolicies = loadState < { policies ?: Record < string , EffectivePolicySummary > } > ( 'libresign' , 'effective_policies' , { policies : { } } )
46- return Object . values ( effectivePolicies ?. policies ?? { } ) . some ( ( policy ) => {
47- const hasDelegatedRules = ( policy . groupCount ?? 0 ) > 0 || ( policy . userCount ?? 0 ) > 0
48- return hasDelegatedRules && policy . editableByCurrentActor === true
49- } )
50- }
51-
5228const routes : RouteRecordRaw [ ] = [
5329 // public
5430 {
@@ -212,12 +188,6 @@ const routes: RouteRecordRaw[] = [
212188 {
213189 path : '/f/policies' ,
214190 name : 'Policies' ,
215- beforeEnter : ( ) => {
216- if ( ! canAccessPoliciesRoute ( ) ) {
217- return { name : 'Preferences' }
218- }
219- return true
220- } ,
221191 component : ( ) => import ( '../views/Policies/Policies.vue' ) ,
222192 } ,
223193 {
0 commit comments