Try
public class EntitiesPermissionValueProvider : PermissionValueProvider
{
public override string Name => "UE";
public EntitiesPermissionValueProvider(IPermissionStore permissionStore)
: base(permissionStore)
{
}
public override Task<PermissionGrantResult> CheckAsync(PermissionValueCheckContext context)
{
if (CheckAsync(context.Principal))
{
return Task.FromResult(PermissionGrantResult.Granted);
}
return Task.FromResult(PermissionGrantResult.Undefined);
}
public override Task<MultiplePermissionGrantResult> CheckAsync(PermissionValuesCheckContext context)
{
var permissionNames = context.Permissions.Select(x => x.Name).ToArray();
if (CheckAsync(context.Principal))
{
return Task.FromResult(new MultiplePermissionGrantResult(permissionNames, PermissionGrantResult.Granted));
}
return Task.FromResult(new MultiplePermissionGrantResult(permissionNames, PermissionGrantResult.Undefined));
}
private bool CheckAsync(ClaimsPrincipal principal)
{
return principal?.FindFirst("User_Type")?.Value == "SystemAdmin";
}
}
Hi,
Add tenants by code ....
For users, roles, you can refer : https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs#L70
For tenantns, you can use TenantAppService.CreateAsync
method. it will also initialize the tenant data.
https://github.com/abpframework/abp/blob/dev/modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/TenantAppService.cs#L52
For organisations, you can inject IOrganizationUnitManager
to create , delete ... an organisation.
Delete old tenants
You just need to inject Repositpry
and use DeleteAsync
mehtod , like https://github.com/abpframework/abp/blob/dev/modules/tenant-management/src/Volo.Abp.TenantManagement.Application/Volo/Abp/TenantManagement/TenantAppService.cs#L94
Hi,
We will write a release log and migration guides for each major version, like : https://blog.abp.io/abp/ABP.IO-Platform-v4.0-RC-Has-Been-Released-based-on-.NET-5.0, https://docs.abp.io/en/abp/4.0/Migration-Guides/Abp-4_0
You need to pay attention to them.
Override Resolve and resolveAsync methods
Hi,
Can I check it remotely? shiwei.liang@volosoft.com
Hi,
I can't reproduce the problem. Can you use the CLI to create a simple project to reproduce?
Hi,
In 4.2.0 we started using asynchronous methods, try:
[Dependency(ReplaceServices = true)]
public class MyConnectionStringResolver : MultiTenantConnectionStringResolver
{
private readonly IStringEncryptionService _encryptionService;
public MyConnectionStringResolver(
IOptionsSnapshot<AbpDbConnectionOptions> options,
ICurrentTenant currentTenant,
IServiceProvider serviceProvider,
IStringEncryptionService encryptionService) : base(options, currentTenant, serviceProvider)
{
_encryptionService = encryptionService;
}
public override async Task<string> ResolveAsync(string connectionStringName = null)
{
var connectionString = await base.ResolveAsync(connectionStringName);
return _encryptionService.Decrypt(connectionString);
}
}
I will check it out