This sample is developed in response to the following questions on the CUBA support forum:
- https://www.cuba-platform.com/support/topic/company-selector-in-main-window
- https://www.cuba-platform.com/discuss/t/extend-user-of-cuba-platform-with-new-attribute-manager/3213
The application contains the BusinessUser enity, that refers to the system User, which comes along with CUBA and used for security and auth purposes. A business user also encapsulates additional information that is used by the business logic of your CUBA application. In this sample it has an additional reference to the Company enity.
The application retrieves information about the related business user for a logged-in user
and adds it into the session attribures, so it can be taken from it at any time. Find the implementation of this part here, it handles the UserLoggedInEvent
event and add the required session attribute.
In the main screen implementation contains an example of how you can access this session attribute from the controller. It sets a lookup field (in the top right corner) to a value, that is saved in the business user coming from session attributes.
- Read about the global application login actions in the official documentation. Find how to hook the events here and how it is implemented in this project here.
- Learn how to manipulate with the session attributes by reading this chapter of the docs.
- Find information on how to extend the main screen here or just click a few times in the CUBA Studio and it will scaffold an extension for the main screen for you.
- Find another way of extending the system user entity in this sample.