thanks, for now i can't but i will try to upload it
i don't understand what do you mean by share project ?
thanks, still same error Autofac.Core.Registration.ComponentNotRegisteredException: 'The requested service 'SCISP.Data.OverrideAdminPermissionDataSeedContributor' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(PermissionDataSeedContributor), typeof(IDataSeedContributor))]
public class OverrideAdminPermissionDataSeedContributor : PermissionDataSeedContributor
{
private readonly IPermissionDefinitionManager _permissionDefinitionManager;
public OverrideAdminPermissionDataSeedContributor(
IPermissionDefinitionManager permissionDefinitionManager,
IPermissionDataSeeder permissionDataSeeder,
ICurrentTenant currentTenant)
: base(permissionDefinitionManager, permissionDataSeeder, currentTenant)
{
_permissionDefinitionManager = permissionDefinitionManager;
}
public override async Task SeedAsync(DataSeedContext context)
{
var permissions = await _permissionDefinitionManager.GetPermissionsAsync();
var permissionNames = permissions
.Where(p => !p.Providers.Any() || p.Providers.Contains(RolePermissionValueProvider.ProviderName))
.Select(p => p.Name)
.Where(x => !x.StartsWith("SCISP.")) // Exclude all SCISP.* permissions from admin
.ToArray();
await PermissionDataSeeder.SeedAsync(
RolePermissionValueProvider.ProviderName,
"admin",
permissionNames
);
}
}
solved thanks i added this
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddTransient<OverrideAdminPermissionDataSeedContributor>();
context.Services.AddTransient<IDataSeedContributor, OverrideAdminPermissionDataSeedContributor>();
}
}
in SCISPDbMigratorModule
Autofac.Core.Registration.ComponentNotRegisteredException: 'The requested service 'SCISP.Data.OverrideAdminPermissionDataSeedContributor' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
public class PermissionDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly IPermissionManager _permissionManager;
public PermissionDataSeedContributor(IPermissionManager permissionManager)
{
_permissionManager = permissionManager;
}
public async Task SeedAsync(DataSeedContext context)
{
await SeedContentPermissionsForCreatorAsync("ContentCreator");
await SeedContentPermissionsForManagerAsync("ContentManager");
await SeedRequestPermissionsForManagerAsync("ContentManager");
// Remove SCISP permissions from Admin
await RemoveSCISPContentPermissionsFromAdminAsync("admin");
}
private async Task SeedContentPermissionsForCreatorAsync(string roleName)
{
var basePermission = await _permissionManager.GetForRoleAsync(roleName, "SCISP.Content");
if (!basePermission.IsGranted)
{
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content.View", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content.Create", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content.Edit", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content.Delete", true);
}
}
private async Task SeedContentPermissionsForManagerAsync(string roleName)
{
var viewPermission = await _permissionManager.GetForRoleAsync(roleName, "SCISP.Content.View");
if (!viewPermission.IsGranted)
{
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content.View", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Content.Delete", true);
}
}
private async Task SeedRequestPermissionsForManagerAsync(string roleName)
{
var requestViewPermission = await _permissionManager.GetForRoleAsync(roleName, "SCISP.Requests.View");
if (!requestViewPermission.IsGranted)
{
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Requests", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Requests.View", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Requests.Approve", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Requests.Reject", true);
await _permissionManager.SetForRoleAsync(roleName, "SCISP.Requests.Return", true);
}
}
private async Task RemoveSCISPContentPermissionsFromAdminAsync(string roleName)
{
var scispPermissions = new[]
{
"SCISP", // Add parent permission to ensure it's removed
"SCISP.Content",
"SCISP.Content.View",
"SCISP.Content.Create",
"SCISP.Content.Edit",
"SCISP.Content.Delete",
"SCISP.Requests",
"SCISP.Requests.View",
"SCISP.Requests.Approve",
"SCISP.Requests.Reject",
"SCISP.Requests.Return"
};
foreach (var permission in scispPermissions)
{
await _permissionManager.SetForRoleAsync(roleName, permission, false);
}
}
}
}
when run migrator project it is sucees remove permissions from admin of roles ContentCreator and ContentManager permissions but if stop application and run migrator again admin has ContentCreator and ContentManager permissions not i don't use redis
private void ConfigureDistributedLocking(
ServiceConfigurationContext context,
IConfiguration configuration)
{
if (AbpStudioAnalyzeHelper.IsInAnalyzeMode)
{
return;
}
context.Services.AddSingleton<IDistributedLockProvider, NoOpDistributedLockProvider>();
//context.Services.AddSingleton<IDistributedLockProvider>(sp =>
//{
// var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!);
// return new RedisDistributedSynchronizationProvider(connection.GetDatabase());
//});
}
how to fix
[maliming] said: Great 👍
thanks for your response and support