nyambati/express-acl

Cannot set other configuration options if rules field is set.

dominicrathbone opened this issue · 4 comments

https://github.com/nyambati/express-acl/blob/73f4c96c0cd3cc326c8c0c90882645d3d840acb3/lib/index.js#L20,L25

I am trying to use the rules properties to set my rules instead of a json/yaml file but it seems to short circuits the config function before it sets the rest of my configuration properties. Is there a different way to deal with this use case?

I have got around this for now by calling the config function twice:

Once with the configuration properties, excluding rules, wrapped in a try/empty catch (to deal with the filePath error) and a second time with the rules.

try {
  acl.config(aclConfiguration, aclResponse);
} catch (err) {
}

acl.config({ rules: [publicRule, userRule, adminRule] }, aclResponse);

@dominicrathbone Thanks for raising this, I will look into this and keep you updated on the progress.

Thanks, great job otherwise!

@dominicrathbone Just made the changes can you review the PR and let me know if this fixes your issue. You review will be appreciated.