From a25da4e1ca5ad5443d9d2aba45c5ec90b93f96ce Mon Sep 17 00:00:00 2001 From: Verdi Date: Thu, 31 Oct 2019 14:02:43 -0500 Subject: [PATCH] Correct bug in #5 --- src/Middleware/GuardInit.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Middleware/GuardInit.js b/src/Middleware/GuardInit.js index 45d727d..6279e63 100644 --- a/src/Middleware/GuardInit.js +++ b/src/Middleware/GuardInit.js @@ -11,8 +11,13 @@ const { Guard } = require('@slynova/fence') class GuardInit { async handle (ctx, next) { + /** Override denies method to work with async **/ + Guard.prototype.denies = async function (ability, resource, user) { + return !(await this.allows(ability, resource, user)) + } + const guard = Guard.setDefaultUser(ctx.auth.user || null) - + /** * Adding guard in the context */