vue-browser-acl icon indicating copy to clipboard operation
vue-browser-acl copied to clipboard

Potential fix for strict mode bug

Open Hawxy opened this issue 4 years ago • 2 comments

Hello @mblarsen,

I was testing strict mode and noticed that it doesn't appear to work correctly.

As metas in the route guard filters out routes without can, you can end up with an empty metas array, then chainCans will simply resolve true via the reduce's initialValue and bypass the strict mode checks entirely.

The test in this PR currently fails, demonstrating the behavior.

Hawxy avatar Jan 28 '21 14:01 Hawxy

Thanks for the time you've taken to create the tests. Currently I don't have the time to work on it. Would you be able to try making a PR for it?

mblarsen avatar Feb 04 '21 02:02 mblarsen

I added a potential fix for this issue, however I'm unsure what the behavior should be if the fallback route itself has no can meta, without a check in place the router guard just infinitely loops. I've set it to bypass any checks on the fallback route if strict mode is enabled, but perhaps it should throw an error instead.

Hawxy avatar Feb 07 '21 07:02 Hawxy