Skip to content

Commit 3e18618

Browse files
committed
revert(router): remove policies route guard, nav already controls visibility
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent b912db2 commit 3e18618

1 file changed

Lines changed: 0 additions & 30 deletions

File tree

src/router/router.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { createRouter, createWebHistory, type Router, type RouteRecordRaw } from 'vue-router'
77

8-
import { getCurrentUser } from '@nextcloud/auth'
98
import { loadState } from '@nextcloud/initial-state'
109
import { 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-
5228
const 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

Comments
 (0)