Building a JSON Structure to Store Rules for Web Requests

herria

New Member
I'm trying to store rules for web requests in a JSON object and am having trouble thinking of a good structure. Here are some examples of my rules:Possible Conditions\[code\]the user must be logged inthe user must belong to an account of type [____]the user must belong to an account named [___]the user must have a username [___]the user must have the account role [___]the current time must be between [___] and [___]the variable [___] must be set to [___]\[/code\]Possible Success Actions\[code\]allow access to the requested viewredirect to download a specific file\[/code\]Possible Failure Actions\[code\]redirect to a certain view to display reasons why access was deniedredirect to a purchase pageredirect to a login page with a notice explaining why access was denied\[/code\]I need to store multiple rules in a single object. I also need to be able to store boolean relationships like this:\[code\](rule1 && rule2) || rule3\[/code\]Object structure normally comes easy to me, but I'm struggling putting this together. Here's an example of a requirement the JSON object should be able to store:A user can access the control panel if they are logged in and belong to an account named "Owners". If the user has the account role "Employee" then they can only login during Monday-Friday, not weekends. If the user has the name "root" they can login regardless of any other rule. If none of the rules succeed, then redirect the user to a page telling them specifically why they are unable to get to the control panel. E.g., "It's the weekend and you are only allowed to login Monday-Friday."
 
Back
Top