- ABP Framework version: v9.0.0
- UI Type: Angular
- Database System: EF Core (PostgreSQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): no
- Exception message and full stack trace:
- Steps to reproduce the issue:
I have followed this tread https://abp.io/support/questions/5490/Need-to-refresh-the-list-of-static-permission-definitions-without-site-reload?CurrentPage=1 and I've managed to get the permission to show up in my roles.
Here is a quick simple flow of what I want to do. I have module to create either a branch or a state and I would like it directly tied to permissions. So, meaning a role can have several branches/states (permission). When I create a branch/state, it should show up in my permissions for me to assign under roles.
Here is where I create a branch.
and it does show up after I created the branch, without actually needed to restart the API. But it is showing up at the bottom, it should be under 'States' Like the above as its parent is under 'Pulau Pinang'. From what I got is that it is correctly assigned but somehow not showing up properly under its parent state. This is fixed if I restart the API(Swagger), is there anyway where I don't have to restart the API?
The more crucial issue here is when I check that permission and save it. It does not save it.
When I debug it, it goes to SetAsync()
in PermissionManager
class
the PermissionDefinitionManager
cant seem to find the permission.
Here is how I insert the permission:
// Add Branch
if (branch is not null && state is not null && input.FilterFieldID.Equals(branch.Id))
{
var branch_state = input.FilterValueParts.FirstOrDefault(x => x.ID.Equals(state.Id))?.Value.Replace(" ", "");
var statePermission = await _permissionDefinitionManager.GetAsync(KMSv4Permissions.States.Default + "." + branch_state);
if(statePermission is not null)
{
statePermission.AddChild("KMSv4.Branches." + f.Value.Replace(" ", ""), L(f.Value));
await _staticPermissionDefinitionStore.AddPermissionDefinitionAsync(statePermission.Name, statePermission);
}
}
// Add State
if (state is not null && input.FilterFieldID.Equals(state.Id))
{
var statePermission = await _permissionDefinitionManager.GetAsync(KMSv4Permissions.States.Default);
string state_permission_name = KMSv4Permissions.States.Default + "." + f.Value.Replace(" ", "");
if (statePermission is not null)
{
statePermission.AddChild(state_permission_name, L(f.Value));
await _staticPermissionDefinitionStore.AddPermissionDefinitionAsync(statePermission.Name, statePermission);
}
}
and here is a function I followed in the thread mentioned above.
public class ExtendedStaticPermissionDefinitionStore : StaticPermissionDefinitionStore, IExtendedStaticPermissionDefinitionStore
{
public ExtendedStaticPermissionDefinitionStore(IServiceProvider serviceProvider, IOptions<AbpPermissionOptions> options) : base(serviceProvider, options)
{
}
public Task AddPermissionDefinitionAsync(string key, PermissionDefinition permissionDefinition)
{
if (!PermissionDefinitions.ContainsKey(key))
{
PermissionDefinitions.Add(key, permissionDefinition);
}
return Task.CompletedTask;
}
}
public interface IExtendedStaticPermissionDefinitionStore : IStaticPermissionDefinitionStore
{
Task AddPermissionDefinitionAsync(string key, PermissionDefinition permissionDefinition);
}
Thanks!
10 Answer(s)
-
0
hi
The permission group and permissions get from
https://github.com/abpframework/abp/blob/dev/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs#L35-L107
You can debug this app service to see the data.
The more crucial issue here is when I check that permission and save it. It does not save it.
Please create a new question for this.
Thanks.
-
0
Hi,
I've got this from https://github.com/abpframework/abp/blob/dev/modules/permission-management/src/Volo.Abp.PermissionManagement.Application/Volo/Abp/PermissionManagement/PermissionAppService.cs#L35-L107
its correct, just that in the UI its not displaying correctly unless I restart the API (swagger)
-
0
Hi,
I have created a new ticket for the other issue here https://abp.io/support/questions/8410/Unable-to-save-the-permission-after-creating-it-in-an-App-Service
Thanks!
-
0
hi
its correct, just that in the UI its not displaying correctly unless I restart the API (swagger)
Can you check the JSON data in the browser(angular)?
Get api/permission-management/permissions?providerName=x&providerKey=y
-
0
-
0
hi
Does it mean the angular UI page shows the data in the wrong order?
If so, I will ask our angular team.
-
0
Yes it is, it is under not under the parent
-
0
ok. I will ask our angular team.
-
0
Thanks!
-
0
: )