There is an API on the Yii2 framework. with RBAC user roles. At the moment, the frontend of the site is being written on Backbone.js . As planned by the site, each user role has its own display page and data. But for each role, the output data is significantly different, and so is the different page markup, the output widgets, etc.
Question: Suppose there is a common user authentication page /#auth in backbone.js, how can I load the necessary data depending on the user role being returned?
My suggested answer is: place the frontend files of backbone.js inside the yii2 framework. Leave the authorization page on the Yii2 GUI with the /auth page, determine what role this user uses and download the necessary module / controller that registers the index.view file - in which the single-page backbone already befriends. This will solve the problem of how to use different roles. Each role will have its own application on the backbone. Okay .. but if this option is viable, authentication is performed on yii2, after which the system redirects me to the desired action and loads the backbone. How can I load models and collections with data from server API? It seems like I am authenticated through yii2, but the backbone knows nothing about me ?! Help to guess ?! how best to do it all?