0

I created a default solution from BoilerPlate's website with angular. I need to create a new permission to assign to a user. So I added it in my authorization provider:

public class PilotoConciliacaoAuthorizationProvider : AuthorizationProvider
{
    public override void SetPermissions(IPermissionDefinitionContext context)
    {
        context.CreatePermission(PermissionNames.Pages_Users, L("Users"));
        context.CreatePermission(PermissionNames.Pages_Users_Activation, L("UsersActivation"));
        context.CreatePermission(PermissionNames.Pages_Roles, L("Roles"));
        context.CreatePermission(PermissionNames.Pages_Tenants, L("Tenants"), multiTenancySides: MultiTenancySides.Host);
        context.CreatePermission(PermissionNames.Pages_CadastrarPdv, L("TituloCadastrarPdv"), multiTenancySides: MultiTenancySides.Host);
    }

    private static ILocalizableString L(string name)
    {
        return new LocalizableString(name, PilotoConciliacaoConsts.LocalizationSourceName);
    }
}

In the case, it's PermissionNames.Pages_CadastrarPdv. I've created the constant and the localizable resource.

But when I run the GetAllPermissions service, it only gets 3 of them:

"result": {
    "items": [
      {
        "name": "Pages.Roles",
        "displayName": "Funções",
        "description": null,
        "id": 0
      },
      {
        "name": "Pages.Users.Activation",
        "displayName": "Users activation",
        "description": null,
        "id": 0
      },
      {
        "name": "Pages.Users",
        "displayName": "Usuários",
        "description": null,
        "id": 0
      }
    ]
  },
  "targetUrl": null,
  "success": true,
  "error": null,
  "unAuthorizedRequest": false,
  "__abp": true

What am I missing?

Thanks in advance.

Lombardo
  • 21
  • 5

1 Answers1

0

What happening is that you've specified this permission just for host user, as I can see you are logged as a tenant so you won't see this permission neither tenant permission.

If you need MultiTenancy active and you need this permission to all users you have to remove this section of permission especification and put it like this:

    context.CreatePermission(PermissionNames.Pages_CadastrarPdv, L("TituloCadastrarPdv"));

If you don't need to use MultiTenancy, you can disable it on:

YourProjectName.Core\YourProjectNameConsts.cs there you'll find a variable

public const bool MultiTenancyEnabled = true; change it to false if you don't need to use it.

You can call ready the entire documentation for Authorization here:

AspnetBoilerplate - Authorization

José Polanco
  • 574
  • 4
  • 19