vue-authorize icon indicating copy to clipboard operation
vue-authorize copied to clipboard

Can't acces to permissions

Open sorribes22 opened this issue 7 years ago • 0 comments

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.

  1. Using v-if-authorized directive returns me Failed to resolve directive: if-authorized. If I use the "old" directive v-is-authorized it doesn't return me any error.

  2. 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 in main.js... But it doesn't detect the permissions from the view using v-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
        }
      }
    }
  }
  1. Is necessary to define some roles to make it works? Because i founded into src/authorize.js@isAuthorized the 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

sorribes22 avatar Mar 19 '18 11:03 sorribes22