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

middleware pipeline issue #19

Open
bci24 opened this issue Feb 7, 2022 · 0 comments
Open

middleware pipeline issue #19

bci24 opened this issue Feb 7, 2022 · 0 comments

Comments

@bci24
Copy link

bci24 commented Feb 7, 2022

Hello,

Am using this project and I found an issue with middleware.

On my app I check for admin by role. In store -> Auth.js

isAdmin: (state) => {
    return state.user ? state.user.role === 'admin' : false;
}

I have created and tested with another role manager:

isManager: (state) => {
    return state.user ? state.user.role === 'manager' : false;
}

and in the index.js route:

{
    path: '/domains',
    name: 'domain',
    meta: { middleware: [auth, admin, manager]},
    component: () => import......
}

Created a middleware manager:

export default function manager({ next, store }) {
  if (store.getters["auth/isManager"]) next();
  else next({ name: "notFound" });
}

When I login with user role manager the route 'domain' works. If I login with admin it gives 404 (notFound)

It seems like it persist the last middleware (if I am logged is as admin and the last middleware is manager) it gives notFound from manager middleware.

Any idea how can I make it work for both admin and manager ?

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

1 participant