Base solution for your next web application
Open Closed

Permissions in abp.auth not set in client #385


User avatar
0
samvh created

Hello!

I followed the documentation to create a permission system. At the moment it is working in my ApplicationServices (PermissionChecker.IsGranted....) but not in my client. Here is what I got:

AbpPermissions table:

[Id] [Name] [IsGranted] [CreationTime] [CreatorUserId] [RoleId] [UserId] [Discriminator]
  1   Admin      1          2015..          NULL         1       NULL    RolePermi...

Application > Authorization > ProjectAuthorizationProvider:

public override void SetPermissions(IPermissionDefinitionContext context)
{
    context.CreatePermission("Admin", new FixedLocalizableString("Admin"));
}

Application > ProjectApplicationModule:

public override void PreInitialize()
{
    Configuration.Authorization.Providers.Add<ProjectAuthorizationProvider>();
}

userController.js:

vm.permissions = {
    admin: abp.auth.hasPermission("Admin")
}

console.log(vm.permissions.admin); // returns false (abp.auth does not have any auth information)

I logged in with my adminstrator (roleid = 1).

I Compared to the github examples but cannot find anything different. What am I missing? Thanks!


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

    Hi,

    Your code seems correct in general. Can you try to open /AbpScripts/GetScripts from browser (and be sure it's not caches. you can open like that for example: /AbpScripts/GetScripts?v=635794287665549658). Can you see abp.auth section? Can you see your permission here?

    Are you using module-zero (or AspNet Zero) or you completely custom implemented permission system? If it's custom, can you share your IPermissionChecker implementation?