You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add ability to map users to multiple companies with FullMultipleCompanySupport
We have a hierarchical set of companies grouped in multiple layers:
a) the upper layer must have access to all companies
b) the lowest layer must be scoped to only one company
c) the middle layer must have access to multiple companies of the lowest layer, but not all of them
a) and b) is possible with FullMultipleCompanySupport and super user, but c) is currently not supported.
To accomplish this, I propose the concept of "mapped" companies.
Users with a mapped company can see and update all resources of the mapped company according to the users permissions, just like the "primary" company.
A new mapping table is created and linked to users and companies and the company scoping function is updated accordingly.
The mapping table only contains additional mappings, not the "primary" company of the user.
In the user edit view a new tab is created to map users to companies.
The validation logic must be changed for this. Currently a scoped user can't change the company.
Now it must be possible for users with mapped companies to choose between companies.
To do this, two changes are needed:
- the company selectlist gets scoped to the primary and the mapped companies
- a new validator is introduced to validate if the user is allowed to choose a company or if a company is required. This validator handles input through the UI and the API
The logic if a user is edited must be changed accordingly:
- If a different "primary" company is assigned to a user, the mapping table must be updated.
- Bulk editing this must also be supported.
- If a user gets cloned, the mappings must be cloned.
I implemented this feature with performance and backward compatibility in mind. There is no overhead if FullMultipleCompanySupport is disabled.
The feature is fully optional, there is only minimal overhead if FullMultipleCompanySupport is enabled and no mappings are used.
0 commit comments