Permission Management Algorithm
- by Emerald214
I have 3 levels of permission to see the product:
Brand - Allow/Deny
Category - Allow/Deny
Product - Allow/Deny
For example, product A has:
Category: Allow
Product: Deny
= product A cannot be seen because product A isn't allowed in Product level.
if(allowForCategory == true) {
if(allowForProduct == false) return false;
if(allowForProduct == true) return true;
} else {
...
}
This is not a good choice because it will become more complex if we add brand level.
if() {
if() {
if() {}
}
}
So is there any general algorithm to deal with the permission problem just like 777 solution in Linux?