I’m trying to port an existing backend to CUBA, to see its potential.
I have the following scenario (simplified):
- A given user (someone who can login) can be one or more of the following classes (roles?): Teacher, Parent, Employee
- Based on their classes/roles as above, they can have additional properties (most of them mandatory). For example a teacher must have a type and is associated with one or more grades.
- A single logged in user can play the above roles simultaneously, and these roles can be changed later on. For example, a teacher can become a Parent at a later time, and when it happens the system must ask for the additional fields that are mandatory for a Parent.
What’s the best way to achieve this in CUBA?
I’ve seen that we’re able to extend the User entity, and add custom fields, but I don’t want to ask for fields that are useless (for example asking for the teacher type if the user is only a Parent). In addition I’d like to let the User entity have only the generic fields a login user should have…
In my current solution, I’ve implemented different entities/tables (Teacher, Parent, etc.) and added a one-to-one reference to a common User table. When I register a new User, I dynamically add/remove rows in the other tables based on the user classes/roles.
I’d like to follow a best-practice recommendation that fits well within the CUBA architecture…
Thanks for your support,