Skip to content

VueRouter meta evaluation by providing a callback that returns a promise doesn't work as expected #22

Open
@ricardo17coelho

Description

@ricardo17coelho

If the "can" rule returns false, no page will be rendered ( empty page )

{
  path: 'posts/:postId',
  component: PostEditor,
  meta: {
    can: (to, from, can) => {        
      return axios.get(`/api/posts/${to.params.id}`)
        .then((response) => can('edit-post', response.data));
    },
    onDeniedRoute: '/unauthorized'
  }
}

This can be easy tested with the playground example here: https://github.com/victorybiz/vue-simple-acl/blob/master/playground/src/main.ts#L30

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