Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

currentUserHasPermissions function with ViewListItems returns false for a full control user #509

Closed
nemesgabor opened this issue Jun 30, 2017 · 4 comments

Comments

@nemesgabor
Copy link

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!

@patrick-rodgers
Copy link
Contributor

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?

pnp.sp.web.currentUser.select("LoginName").get()

@nemesgabor
Copy link
Author

Thanks for the quick reply, appreciate it.
I've updated to v2.0.6.

I have the same issue in O365, when i call currentUserHasPermissions, i get false back.
I've checked, the logins match in both environments, i got the same results using a login name, and using the "currentUser" functions.

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.

image

@patrick-rodgers
Copy link
Contributor

patrick-rodgers commented Jul 5, 2017

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.

@patrick-rodgers
Copy link
Contributor

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!

patrick-rodgers added a commit that referenced this issue Jul 5, 2017
Fix for #509 - handle verbose mode for getUserEffectivePermissions
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants