williamcruzme / vue-gates

🔒 A Vue.js & Nuxt.js plugin that allows you to use roles and permissions in your components or DOM elements, also compatible as middleware and methods.

Home Page:https://williamcruzme.github.io/vue-gates/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using persistent causes an error

strotgen opened this issue · comments

Hi John, thanks for developing this package.

I upgraded recently and started getting the following error:

Uncaught SyntaxError: Unexpected token u in JSON at position 0
    at JSON.parse (<anonymous>)
    at new Gate (vue-gates.js?e1b1:221)
    at Object.install (vue-gates.js?e1b1:323)
    at Function.Vue.use (vue.runtime.esm.js?2b0e:5107)
    at eval (vue-gates.js?511d:4)
    at Module../plugins/vue-gates.js (app.js:951)

Checking the source code, I saw that the constructor is trying to parse localStorage.getItem('roles') but this returns undefined, hence the error.

I'm using Nuxt, latest version. And I set the roles and permissions inside a Nuxt Auth plugin.

Is this an expected behaviour or am I doing something wrong? If not, I can PR a quick fix for this.