How to integrate with active directory in mvc core razor
The website appears in English when opening in a new incognito window while default language is arabic in abp framewrok mvc core multi layer
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 Test permissions from Admin
await RemoveTestContentPermissionsFromAdminAsync("admin");
}
private async Task SeedContentPermissionsForCreatorAsync(string roleName)
{
var basePermission = await _permissionManager.GetForRoleAsync(roleName, "Test.Content");
if (!basePermission.IsGranted)
{
await _permissionManager.SetForRoleAsync(roleName, "Test.Content", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Content.View", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Content.Create", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Content.Edit", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Content.Delete", true);
}
}
private async Task SeedContentPermissionsForManagerAsync(string roleName)
{
var viewPermission = await _permissionManager.GetForRoleAsync(roleName, "Test.Content.View");
if (!viewPermission.IsGranted)
{
await _permissionManager.SetForRoleAsync(roleName, "Test.Content", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Content.View", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Content.Delete", true);
}
}
private async Task SeedRequestPermissionsForManagerAsync(string roleName)
{
var requestViewPermission = await _permissionManager.GetForRoleAsync(roleName, "Test.Requests.View");
if (!requestViewPermission.IsGranted)
{
await _permissionManager.SetForRoleAsync(roleName, "Test.Requests", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Requests.View", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Requests.Approve", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Requests.Reject", true);
await _permissionManager.SetForRoleAsync(roleName, "Test.Requests.Return", true);
}
}
private async Task RemoveTestContentPermissionsFromAdminAsync(string roleName)
{
var TestPermissions = new[]
{
"Test", // Add parent permission to ensure it's removed
"Test.Content",
"Test.Content.View",
"Test.Content.Create",
"Test.Content.Edit",
"Test.Content.Delete",
"Test.Requests",
"Test.Requests.View",
"Test.Requests.Approve",
"Test.Requests.Reject",
"Test.Requests.Return"
};
foreach (var permission in TestPermissions)
{
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
thanks but it is give me error InvalidOperationException: The partial view '_ValidationScriptsPartial' was not found. The following locations were searched: /Pages/_ValidationScriptsPartial.ar.cshtml /Pages/_ValidationScriptsPartial.cshtml /Pages/Shared/_ValidationScriptsPartial.ar.cshtml /Pages/Shared/_ValidationScriptsPartial.cshtml /Views/Shared/_ValidationScriptsPartial.ar.cshtml /Views/Shared/_ValidationScriptsPartial.cshtml
why client validation not working in web public project mvc core razor
thanks but i want from code how
thanks for quick replay , which project i will make this note i'm using mvc core multi layer and all languages appear in project web, and please give me full code or i mean full fix
I want to remove all languages expect Arabic and English how