Yes the permission is still null.
I have email you the test project. Thanks!
1. Run the API and Angular
2. Login with default admin credentials
3. Head to “Group Management”
4. Click “+New Group” on top right corner
5. In the dropdown “Filter Type” select “State”
6. Give it a testing name and a code.
7. Click “Save”
8. Head to “Administration” > “Identity Management” > “Roles” > “admin” > “Permission”
9. The newly created permission is under the Group KMSv4
10. Scroll all the way down, and check the newly created state and select save.
11. Reopen the permission menu to see if it is assigned.
Note: the code for adding the new permission in the “Group Management” is in the FilterValueAppService.cs
Yes it is, it is under not under the parent
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!
I tried to create a permission using Static Permission Definition Store and without restarting the API (Swagger) I am unable to save the permission.
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 created by following https://abp.io/support/questions/5490/Need-to-refresh-the-list-of-static-permission-definitions-without-site-reload?CurrentPage=1.
public class ExtendedStaticPermissionDefinitionStore : StaticPermissionDefinitionStore, IExtendedStaticPermissionDefinitionStore
{
public ExtendedStaticPermissionDefinitionStore(IServiceProvider serviceProvider, IOptions 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!
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)
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!
Hi,
I see, let me try to delete and import accordingly.
Thanks!