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

permissions gets updated after page refresh.

Open Xatta-Trone opened this issue 3 years ago • 1 comments

Hello, thank you for this awesome plugin.

I am using NUXT js and my problem is....the permissions does not apply automatically until I refresh the page manually.

in login section

async userLogin() {
      try {
        let response = await this.$auth
          .loginWith('laravelSanctum', {
            data: this.login,
          })
          .then((res) => {
            console.log('asdfsf')
            this.$axios
              .get('/admin/permissions')
              .then((res) => this.$gates.setPermissions(res.data))
              // .then((res) => this.$forceUpdate())
              .catch((err) => console.log(err))
          })
      } catch (err) {
        console.log(err)

        if ((err.response.status = 401)) {
          this.getmessage(err.response.data.message)
        } else {
          this.getmessage('Something went wrong')
        }
      }
    },

#in sidebar v-show="$gates.hasPermission('' + item.permission + '')"

after login, I am redirecting to the dashboard page. but there every permission returns false. 

now, if I refresh the page manually, then the permission system works. 

how to resolve this issue ? 

#after login image

#after refresh image

Xatta-Trone avatar Aug 06 '21 06:08 Xatta-Trone

Ho @Xatta-Trone, try this https://github.com/williamcruzme/vue-gates/issues/15#issuecomment-594624573

jhosepharaujo avatar Sep 11 '21 02:09 jhosepharaujo