Base solution for your next web application
Open Closed

Role base authorization in ASP.NET Boilerplate. #2430


User avatar
0
oprakash created

Hi There, I am facing problem with implementing role base authorization in asp.net boilerplate. Tried the below steps. Database

  1. I introduced two new role(Accounts, Sales) to "abpRoles" table.
  2. Added two users with above roles in "AbpUserRoles".
  3. Added many roles to "AbpPermissions" table in respect of Accounts and Sales role.

Code, 4. I added constant string variable in "Core.Authorization.PermissionNames" class. 5. Then In "Core.Authorization.FinanceAuthorizationProvider:AuthorizationProvider " class i set the permission in "SetPermissions" method as below.

public override void SetPermissions(IPermissionDefinitionContext context) { //Common permissions var pages = context.GetPermissionOrNull(PermissionNames.Pages); if (pages == null) { pages = context.CreatePermission(PermissionNames.Pages, L("Pages")); } var users = pages.CreateChildPermission(PermissionNames.Pages_Users, L("Users")); var roles = pages.CreateChildPermission(PermissionNames.Pages_Roles, L("Roles")); }

-- Now when i log in with the users having Accounts, Sales Roles. Not able to get "Role" permission..

Please help.

Thanks and Regards Om Prakash


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

    Hi,

    Can you share the data in [AbpPermissions] table and the TenantId of the user you are using to login ?

    By the way, how do you grant permissions to roles in code ?