adonis-guard icon indicating copy to clipboard operation
adonis-guard copied to clipboard

Async Gate functions issue

Open khalidamiri opened this issue 4 years ago • 2 comments

https://github.com/RomainLanz/adonis-guard/blob/d89338e00dca869e7ac0eb13b3c2e2a8a2dd7508/src/Middleware/Can.js#L14

I believe await should be added to the condition in this line. If an async function is added to Gate.define, this condition will ignore the gate result and allow the unauthorized calls to pass.

khalidamiri avatar Aug 27 '19 15:08 khalidamiri

Yes,

More information on this here: https://github.com/RomainLanz/adonis-guard/issues/5

Would you mind sharing a PR?

RomainLanz avatar Aug 28 '19 08:08 RomainLanz

I created a Can middleware in my project that overrides the middleware in adonis-guard. I only changed the following line in it. if (!await guard.can(auth.user).pass(method).for(argument)) { I can't push to this repo, in case you wanted me to create a PR for this fix.

khalidamiri avatar Aug 28 '19 18:08 khalidamiri