Base solution for your next web application
Open Closed

Permissions are not set from Backend Side. #3767


User avatar
0
vineforce created

Hello Support,

We are trying to set some default permissions to the tenants and don't allow them to update the permissions. But when we are trying to assign those from the backend, then those are not affecting the application. Like we want to assign dashboard permission to one tenant later and we executed the below query to assign but it doesn't affect on the front side.

INSERT INTO AbpPermissions(CreationTime,  Discriminator, IsGranted, Name, TenantId,RoleId)
Values (GETDATE(),'RolePermissionSetting',1,'Pages.Tenant.Dashboard',124,244)

Could you please guide us how we can do this from the backend?

Thanks


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @brightpath,

    Permissions are cached, so you should use RoleManager's GrantPermissionAsync method to grant a permission to a role.

    Thanks.

  • User Avatar
    0
    strix20 created

    <cite>ismcagdas: </cite> Hi @brightpath,

    Permissions are cached, so you should use RoleManager's GrantPermissionAsync method to grant a permission to a role.

    Thanks.

    How are we supposed to do this via migrations?

    We have added a new set of pages with their own permissions (that are non-revokable), so how do we assign those permissions to existing users when we run the database migration?

  • User Avatar
    0
    aaron created
    Support Team

    Restarting the application and AppPool may be sufficient to reset the cache. Alternatively, you can inject ICacheManager and clear the cache yourself:

    _cacheManager.GetRolePermissionCache().Clear();
    _cacheManager.GetUserPermissionCache().Clear();