Why are the results different on Permission Check for my Custom Application?


the permission check is not what I expected.. so for an owner, both of these checks are true. but for say Manager, given the Can Create Map App permission is changed from the default, check1 returns false, check2 returns true.
Should the results both be true?

 public boolCanCreate(int userId, Guid containerTypeId, Guid containerId){
              PermissionCheck check1 = TEApi.Permissions.Get(UI.Permissions.MapAppPermissionRegistrar.CreateGroupMapApps, userId );
              PermissionCheck check2 = TEApi.Permissions.Get(UI.Permissions.MapAppPermissionRegistrar.CreateGroupMapApps, userId,containerId,containerTypeId, _entityPermissionType );
 
            return check1.IsAllowed || check2.IsAllowed;  
            
        }


a related post is here

heads up to     

Parents
  • Are you on version 9?   There is no permission API that takes container Ids, its going to be the content or the application.   If you are on version 9 there is a secondary issue in the fact your version is not  supported any more and a new version of the permissions API was added in version 11.   I highly recommend upgrading

  • yes.. afraid I am on 9.x so... I keep telling my people... 
    Looking forward to upgrading, hope your sales team is letting our leadership know we need to upgrade too.
    we're up on our license, so there's not reason to not upgrade.

    I totally get it.  I understand it maybe too much to ask. you already saved us with your last post. thank you for that.

    The overloads allowed for 'entityId' and entityTypeId, and then the entityPermissionType is application or content, so I using the application enum value option.. 


    I didn't know what an entity could be... 

    since the method is check if the user can create an application, there is not an application Id yet.  But I'll try passing null values see if it's just the application enum value that returns true.

  • EntityType is going to be the contentTypeId or the applicationTypeId, the enum then defines which.   The EntityId will be the ApplicationId or ContentId respectively.  But  no containers, you do not check permissions against a container, it really is on an application, content based checks really will internally resolve up to applications.   I generally prefer application over content if you already have reference to it but content works as well if that the context you are in.

  • I wasn't catching errors.. but in debugging, I noticed it, and it seems the application type needs to be protected.. that maybe why i  am seeing problems... it didn't error out at first but it is now.

  • Ok.. having realized there was an error "the entity type is not secured" so I tried making the type id,  private protected, but clearly I didn't figure it out.  Because of the timing and we really need to upgrade, it looks like the NodePermissions.Get does the trick as well, without the error.. below is what I was working with.. for the "CanEdit". For "CanCreate" I'll try the NodePermission. Patrick brought to light the issue with the application or content id and types, which was on the issue... so the real solution is in his response.. and this is just a work around the error..

    PermissionCheck _canEdit = TEApi.Permissions.Get(UI.Permissions.MapAppPermissionRegistrar.UpdateGroupMapApps, userId, applicationId, _applicationTypeId, _entityPermissionType).IsAllowed
     /***OR**/
     PermissionEntry nodeCheck = TEApi.NodePermissions.Get("MapApps", applicationId, UI.Permissions.MapAppPermissionRegistrar.UpdateGroupMapApps.ToString());

  • Not sure what you mean, ApplicationTypeId is just a guid, the property on your application type plugin has to be public, all of the interface members need to be

Reply Children