Check Fullmask Permission and the Bitwise JS Limit
Category
- [x] Bug
Describe the bug
I use SPFx 1.4 on an SP2019 Environment and want to check the permissions for an user (this.context.pageContext.web.permissions) and if the user has full mask. In my case I have full mask. The values are right: High: "2147483647", Low: "4294967295" BUT the hasPermission-Function returns everytime false.
permission.hasPermission(SPPermission.fullMask) //returns false
When I go to the definition of this Function, it looks like this:
SPPermission.prototype.hasPermission = function (requestedPerm) {
return requestedPerm &&
((requestedPerm.value.Low & this.value.Low) === requestedPerm.value.Low) &&
((requestedPerm.value.High & this.value.High) === requestedPerm.value.High);
};
This condition returns true:
(requestedPerm.value.High & value.High) === requestedPerm.value.High
But this one returns false:
(requestedPerm.value.Low & value.Low) === requestedPerm.value.Low
The reason is, that the bitwise AND returns -1 and not 4294967295
And this happens because JS can only check bitwise in the range of -2147483648 to 2147483647 (see here)
I would say it is not an environment or SPFx Issue, but a JavaScript.
Environment details
- OS: [e.g. Windows 10 | MacOS 10.15.x]
- Target Environment: SharePoint Server 2016 | SharePoint Server 2019 | SharePoint Online
- Framework: spfx
- Browser(s): Chrome
- Tooling: VS Code | SPFx v1.4.0
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We have found the issue and have created a fix for it. The fix should be rolled out in a couple weeks. Let us know if you are still seeing an issue afterwards.
This should be WW now
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues