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

Compatibility with vue-router #27

Open
jcharcosset opened this issue Oct 23, 2020 · 1 comment
Open

Compatibility with vue-router #27

jcharcosset opened this issue Oct 23, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jcharcosset
Copy link

Is it planned an integration with vue-router ?
Could we authorize route depend of roles and/or permissions with meta field

@quantumwebco
Copy link

quantumwebco commented Oct 25, 2020

Currently to integrate with Vue Router I'm putting the check in the beforeEnter callback

    {
        path: '/surveys/:survey_id/edit', component: SurveyForm,
        beforeEnter: (to, from, next) => {
            if (!router.app.$gates.hasAnyRole('Admin|Super Admin') || 
                !!router.app.$store.state.surveys.find(s => s.id === parseInt(to.params.survey_id)) {
                next('/surveys');
            }
            next();
        }
    },

It would be really nice to just pass meta: { middlewares: ['admin', 'owner'] } and if route params were available in the middleware

@williamcruzme williamcruzme self-assigned this Oct 29, 2020
@williamcruzme williamcruzme added the enhancement New feature or request label Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants