currentUserHasPermissions function with ViewListItems returns false for a full control user #509
Comments
Do you see the same issue in O365? I can't reproduce it so unsure what I may be doing that you are - but I don't have a 2013 environment handy. This may be due to differences in the API between 2013 version and now. If there is a bug to fix we will, but need to understand it first. So you want to call the currentUserHasPermissions method and you are saying that the call to "getCurrentUserEffectivePermissions" within that method is returning incorrect data? What I don't follow is that the method you say works "getUserEffectivePermissions" is ultimately called with the current user's login name when you call "currentUserHasPermissions". Are different login names being used in the calls? I.E. when you call "GetUserEffectivePermissions" directly with a login name, does that login name match the one returned from the below call?
|
Thanks for the quick reply, appreciate it. I have the same issue in O365, when i call currentUserHasPermissions, i get false back. I made a screenshot on O365 using a breakpoint, where you can see that value.High, and value.Low will be undefined, because "value = Object {GetUserEffectivePermissions: Object}". The value.GetUserEffectivePermissions contains the low and high attributes, not the value object. |
Are you working in verbose odata mode? Which means the issue is actually in us not handling the verbose vs. non-verbose return value. [Edit] yes this is in fact the issue, fixing now. |
And fixed in number #519. Thanks for reporting this and providing enough info to get it fixed. I am going through the other issues today and will put a beta release out later or you can pull dev and test once the PR is merged. Thanks! |
Fix for #509 - handle verbose mode for getUserEffectivePermissions
currentUserHasPermissions function with ViewListItems returns false for a full control user
Category
[ ] Enhancement
[X ] Bug
[ ] Question
Version
V2.0.5
Sharepoint is onprem 2013
Expected / Desired Behavior / Question
If i can query the list items ( using $pnp.sp.web.lists.getByTitle("Projects").items.get() ), then the $pnp.sp.web.lists.getByTitle("Projects").currentUserHasPermissions($pnp.PermissionKind.ViewListItems) should return true.
Observed Behavior
The $pnp.sp.web.lists.getByTitle("Projects").currentUserHasPermissions($pnp.PermissionKind.ViewListItems) call returns false for a full control user.
The $pnp.sp.web.lists.getByTitle("Projects").getCurrentUserEffectivePermissions() returns this object for a full control user:
{"GetUserEffectivePermissions":
{"__metadata":{"type":"SP.BasePermissions"},
"High":"2147483647",
"Low":"4294967295"}
}
Workaround
In the /src/sharepoint/queryablesecurable.ts the hasPermissions uses value.High , and value.Low, but if it gets the perms.GetUserEffectivePermissions, instead of perms from currentUserHasPermissions and userHasPermissions function, the function starts to return the correct values.
Steps to Reproduce
Try this code on a list on SP2013 where you have at least listing permission:
$pnp.sp.web.lists.getByTitle([listname]).currentUserHasPermissions($pnp.PermissionKind.ViewListItems).then(function(){
console.log(perms);
});
Thanks!
The text was updated successfully, but these errors were encountered: