I am still working on grasping the concepts of DoneJS.
I particularly like the routing:
/:page/:stub/:action
Most of the things I develop require Authentication/Authorization before site functionality can shown.
From a routing perspective, let’s say we have 4 pages/routes:
/login
/home
/chat
/chatAdmin (secured)
If a User is NOT Authenticated, then they should be routed to the login page.
Once User is Authenticated, then the User should be routed to the home page.
Any Authenticated user will have access to the chat page.
A User must be granted the Chat Admin role to have Authorization to view the chatAdmin page.
After successful User Authentication a User Profile object is returned by the Authorization Service containing basic User Info (Name, email, etc) and a list of granted Roles.
The User is then routed to the home page…
In the Nav Bar, Home and Chat are always visible.
Yet ChatAdmin would only be visible if the User was granted the ChatAdmin role.
What type of DoneJS pattern would you recommend to support the above use case?
And/or do you have any examples that might show how to support such a pattern.
Note: It is possible that the UserProfile roles might be used within a Page, View and/or Route to grant/restrict access based on Authorization rules. In such a scenario, the UserProfile object would need to be accessible throughout the code. Would we need to make UserProfile a global object and/or are there any scoping rules that we may need to be aware of here?
Any assistance/information/examples is greatly appreciated!!
Thanks