proper privilege checking

This commit is contained in:
Henry Jameson 2026-06-11 11:40:25 +03:00
commit 20b2e58f6f

View file

@ -402,27 +402,33 @@ const ModerationTools = {
this.privileged('users_manage_tags')
)
},
isAdmin() {
this.$store.state.users.currentUser.role === 'admin'
}
},
methods: {
canGrantRole(name, value) {
const setEntry = `${value ? '!' : ''}rights:${name}`
return (
this.$store.state.users.currentUser.role === 'admin' &&
this.isAdmin &&
this.totalSet.has(setEntry)
)
},
canChangeState(name, value) {
let privilege
switch (name) {
// TODO detailed privileges
default: {
privilege = 'users_manage_activation_state'
}
}
const setEntry = `${value ? '!' : ''}state:${name}`
const privilege = (() => {
switch (name) {
case 'activated':
return 'users_manage_activation_state'
case 'approved':
return 'users_manage_invites'
case 'confirmed':
return 'users_manage_credentials'
default:
return null
}
})()
return this.privileged(privilege) && this.totalSet.has(setEntry)
},
@ -446,6 +452,7 @@ const ModerationTools = {
this.confirmDialogName = null
},
privileged(privilege) {
if (this.isAdmin) return true
return this.$store.state.users.currentUser.privileges.has(privilege)
},
setTag(tag, value) {