vue-authorize
vue-authorize copied to clipboard
Can't acces to permissions
Hi, can you help me? I'm starting to use this package and I have some questions. If you solve me some of this questions will help me a lot.
-
Using
v-if-authorizeddirective returns meFailed to resolve directive: if-authorized. If I use the "old" directivev-is-authorizedit doesn't return me any error. -
I'm trying to get the list of permissions from backend and managing with VueX. Then, the permissions available can change. But it doesn't work for me, I don't know how to implement it. I tryied a lot of things, calling
this.$authenticate.definePermission()when I get permissions, setting it hardcoded like now, and getting, writting it directly inmain.js... But it doesn't detect the permissions from the view usingv-is-authorized="{ permissions: ['repetidor_index'] }"or :
this.$authorize.isAuthorized(null, ['repetidor_index'])
.then(() => {
console.log('it has permission')
})
.catch(() => {
console.log('it does not have permission')
})
main.js
Vue.use(VueAuthorize, store.getters['getPermissionsFormated'])
store/index.js@getters
getPermissionsFormated: (state) => {
return {
roles: {},
permissions: {
repetidor_index: function () {
return true
}
}
}
}
- Is necessary to define some roles to make it works? Because i founded into
src/authorize.js@isAuthorizedthe next code:
return new Promise((resolve, reject) => {
// Does it work if no roles defined??
if (roleInstances.length === 0) {
reject()
}
return Promise.any(roleInstances.map((roleInstance) => {
return roleInstance.invoke(permission, this)
})).then(resolve).catch(reject)
})
Thanks in advanced