Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

Need suggestion on how to support async functions for conditions #28

Closed
loban opened this issue Sep 21, 2019 · 1 comment
Closed

Need suggestion on how to support async functions for conditions #28

loban opened this issue Sep 21, 2019 · 1 comment

Comments

@loban
Copy link

loban commented Sep 21, 2019

This is a great library that I was using in my project, thanks! I especially love how I can express my permissions business logic using

ac.grant('user').execute('action').where(context => SOME LOGIC).on('resource')

However I came upon a wall. I would like to use an asynchronous function in the where clause. But the library does not support that. Any idea how I can go about this?

E.g. I would like to pass a resource_id as the context, and the function would perform an asynchronous database call to ensure that the user has been associated with that resource.

@koladilip
Copy link
Contributor

koladilip commented Sep 24, 2019

I have refactored the whole library to support async condition functions: https://www.npmjs.com/package/role-acl/v/4.0.5 ( any version greater than 4 should be good)

Examples:
https://github.com/tensult/role-acl/blob/develop/test/acl.spec.ts

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants