2 答案
-
0
Hi,
You can consider creating the same role with permissions for tenants 2 and 3 using domain events or override the application service interface of the module
- https://docs.abp.io/en/abp/latest/Local-Event-Bus#pre-built-events
- https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services
Pseudocode:
public class MyIdentityRoleAppService: IdentityRoleAppService { public override async ....CreateAsync() { create role... if(CurrentTenant.Name = "Tenant1") { using(CurrentTenant.Change("Tenant2")) { Create role... } } } }
-
0
Here's another suggestion:
If you can accept data sync delay, you can create a background worker to synchronize tenant and role permissions: https://docs.abp.io/en/abp/latest/Background-Workers#asyncperiodicbackgroundworkerbase
For example:
public class RolePermissionsSynchronizeWorker : AsyncPeriodicBackgroundWorkerBase { public RolePermissionsSynchronizeWorker( AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory ) : base( timer, serviceScopeFactory) { Timer.Period = 600000; //10 minutes } protected async override Task DoWorkAsync( PeriodicBackgroundWorkerContext workerContext) { Logger.LogInformation("Starting: Sync roles..."); ..... Logger.LogInformation("Completed: Sync roles..."); } }