In our applications, we have permission data which is used to enable/disable the current user’s views and abilities. If the a user doesn’t have a permission for a route, the user cannot go to that route or even doesn’t see the links that redirects to that route.
The problem is, we need to retrieve permission data from server before any route loaded. The data retrieved with a promise. So we need to delay routes since the promise is resolved. Do you have any suggestion for this case?
My current options are:
- Return the promise from the application-route’s beforeModel hook. (this can solve the problem but application-route seems unrelevant for permissions.)
- Use application initializer’s deferReadiness method. (instance-initializers may be relevant but i’ve a confusion about initializers. Since the permissions are about the state of the application.)
PS: Of course we have a solid server-side authentication mechanisms on data. As an enterprise application, we have lots of pages and we need a fine-grained permission structure for the pages, buttons and etc. to hide the buttons/pages that cannot be performed by current user.