Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

How to bypass the login prompt popping up to users when he has no permission to a doc lib?

$
0
0

Hi,

I created a page with custom web part using JavaScript to call REST API to load files from a document library. The idea is if a user has permissions to the library, he should see some files, if not, he will just see nothing. However, when a user who does not have permission to the library opens this page, he receives a Login prompt (below is the screenshot). How can I make it not show this prompt but just returns nothing?

My JavaScript code to load files from document library is like below,

functionLoadDocLibFilesNoVersion(docLibServerRelativeUrl){
varret =null;
$.ajax({
url:_spPageContextInfo.webAbsoluteUrl+"/_api/web/getfolderbyserverrelativeurl('"
+ docLibServerRelativeUrl+ "')?$expand=Files,Files/CheckedOutByUser,Files/ModifiedBy,Files/ListItemAllFields",
method:"GET",
async:false,
headers: { "Accept":"application/json; odata=verbose"}
}).done(function (data) {
ret = data;
}).fail(function(xhr,status, error) {
console.log(JSON.stringify(error));
});
returnret;
}

I googled for this issue, only see some suggestions on making changes to registry or on server config, but our desktop is controlled by the firm, we can't make any changes to it, we can't make changes to the server too. So is there a way I can catch this issue in JavaScript?

Thanks,

Michael 



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>