Last active
June 12, 2018 16:56
-
-
Save vaderj/936ee48528ddaba08ae0ef7f27e2ed2b to your computer and use it in GitHub Desktop.
check if the current SP user has a specific permission #Javascript #REST #SharePoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Permission enumeration : https://msdn.microsoft.com/en-us/library/office/ee556747(v=office.14).aspx | |
function checkPermissions() { | |
var call = jQuery.ajax({ | |
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/effectiveBasePermissions", | |
type: "GET", | |
dataType: "json", | |
headers: { | |
Accept: "application/json;odata=verbose" | |
} | |
}); | |
call.done(function (data, textStatus, jqXHR) { | |
var manageListsPerms = new SP.BasePermissions(); | |
manageListsPerms.initPropertiesFromJson(data.d.EffectiveBasePermissions); | |
var approveItems = manageListsPerms.has(SP.PermissionKind.approveItems); | |
//console.log(approveItems); | |
if (approveItems == true){return true} | |
else{return false}; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment