- ABP Framework version: v8.2.0
- UI Type: Blazor Server
- Database System: EF Core (SQL Server)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
Hi. I try to add custom role and set permission for that role. I have researched related creating seed data for customer role and permission. There are some solutions for creating role as seed data and adding all permission into that role. But I want to create several roles other than admin role like standard and basic. Furthermore i want to set specific permissions to them.
Can i define role on this class in order to separate permissions? Shortly I want to - create multiple role as seed data - specify permission for each role while seeding them
<br>
5 Answer(s)
-
0
hi
You can add a
IDataSeedContributor
class and get all permissions, then seeder for a specific role(Line 37
).https://github.com/abpframework/abp/blob/dev/modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeedContributor.cs#L10-L41
-
0
I have seen this. At line 38, it assigns all permission into custom given role. I also want to choose permission from all permission list. Then assign only chosen ones. Is there a practical way to choose permission?
-
0
hi
You can add your logic to filter the permission definitions(
permissionNames
).var permissionNames = (await PermissionDefinitionManager.GetPermissionsAsync()) .Where(p => p.MultiTenancySide.HasFlag(multiTenancySide)) .Where(p => !p.Providers.Any() || p.Providers.Contains(RolePermissionValueProvider.ProviderName)) .Select(p => p.Name) .ToArray();
-
0
Thank you We solved the problem in a different way.
-
0
Great!