Let’s see how we can retrieve the web object and check the permission levels of the current logged in user.
function functionName1(){
SP.SOD.executeFunc('SP.Runtime.js', 'SP.ClientContext',
function() {
SP.SOD.executeFunc('SP.js', 'SP.ClientContext',
function() {
var siteUrl = _spPageContextInfo.webAbsoluteUrl;
var clientContext = new SP.ClientContext(siteUrl);
var web = clientContext.get_web();
clientContext.load(web, 'Title', 'EffectiveBasePermissions');
clientContext.executeQueryAsync(onSuccess, onError);
});
});
}
function onSuccess(){
alert('Title: ' + web.get_title());
var permissions = SP.PermissionKind.manageWeb && SP.PermissionKind.viewListItems;
if(web.get_effectiveBasePermissions().has(permissions)){
alert('user has the required permissions');
}
}
function onError(sender, args) {
alert(args.get_message() + '\n' + args.get_stackTrace());
}