Description
In the original multi-tenant application I designed the App Admin (i.e. a user manages the whole application, not linked to tenant) needed to access the data that a tenant user to understand / fix an tenant user's data.
I will add a "Access data as another tenant user" feature which will override the DataKey of the current user with the DataKey
from the selected tenant user. This provides a App Admin or an Tenant Admin to access the user's data, plus a feature useful in hierarchical multi-tenant applications.
The first thing is to find the tenant user that you want to access their data. This will use the current List AuthP's Users. The list user already has the ability to only return the users that the current user can see, e.g. App Admin can see all user, Tenant Users can only see the users in their tenant.
Once a user has been found you will call the StartAccessToUserDataAsync
method with your found user. This will create a Cookie that will contain the selected user's DataKey
which will override the default DataKey
of the current user. This Cookie should also show a prominent display showing you are in this mode. The StopAccessToUserDataAsync
method will remove the Cookie and return to normal usage.
There are two usages of this feature:
- For the App Admin / customer support users to access a tenant data in order to find / fix a problem reported for a tenant user.
- In a hierarchical multi-tenant application user in a higher level, say a user in the tenant "West Coast" (see hierarchical example) can directly access a lower-level user's data, say the "SanFran shop1". This is especially useful if the "West Coast" tenant user wants to create new entries in the shop, because anything that the higher tenant (e.g. "West Coast") user creates has their DataKey and therefore can't be seen by a lower tenant user.