Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with reading rolesKey #657

Closed
platinumsistemas opened this issue Jul 30, 2021 · 2 comments
Closed

Issue with reading rolesKey #657

platinumsistemas opened this issue Jul 30, 2021 · 2 comments

Comments

@platinumsistemas
Copy link

Hi, currently I'm using the "@websanova/vue-auth": "^2.21.10-beta" for login and I'm trying to make it filter access through roles.

The issue that I have currently is that my user object has a role attribute that is not read by the rolesKey correctly.

Here is the $auth.user()

id: 2
name: "Administrador"
phone: null
role: 1
....

using the next configuration :

options: {rolesKey: 'role'}

meta: {
            auth: {role: 1, redirect: {name: 'login'}, forbiddenRedirect: '/administrador'}
          },

The problem is that I when I use the check Method, this are the results:

    console.log(this.$auth.check()) true
    console.log(this.$auth.check(1)) false
    console.log(this.$auth.check("1")) false
    console.log(this.$auth.check("admin")) false

I would love to know if I need to make the role an object or if I should use a string.

@websanova
Copy link
Owner

It looks correct to me, but that's a a pretty old version, best to update to latest, will probably take less time than trying to fix that :-)

@platinumsistemas
Copy link
Author

platinumsistemas commented Aug 2, 2021

My error was in the
auth: {role: 1, redirect: {name: 'login'}, forbiddenRedirect: '/administrador'}
it was roles as a standard property, not as the name of the property of the object
auth: {roles: 1, redirect: {name: 'login'}, forbiddenRedirect: '/administrador'}

Thanks both for the response and this great package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants