Skip to content

middleware pipeline issue #19

Description

@bci24

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions