Solved! Go to Solution.
What I ended up doing was to test for the presence of ESRI's Identity Manager Dialog using dojo/query, If the dialog was present, I hid the dialog and presented my own error message. Below I've added some code I used to search for this.
var scanForLogin;
arcgisUtils.createMap(agolId, mapDivId, { mapOptions: mapOptions })
.then(onSuccess, onFailure);
// check if a login is required.
require(["dojo/query", "dijit/registry"], function (dojoQuery, registry) {
var loginChecks = 0;
scanForLogin = window.setInterval(function () {
// testing access to sign in node
var signInNode = dojoQuery(".esriSignInDialog"),
promptDialog;
// if there is a signin node
if (signInNode.length) {
promptDialog = registry.byNode(signInNode[0]);
promptDialog.hide(); // hide the prompt dialog
onFailure({message: "Map failed to load properly"});
} else if (this.loginChecks > 4) {
// stops checking after five times (over 3 seconds).
window.clearInterval(this.scanForLogin);
}
loginChecks++;
}, 600);
});
function onSuccess (response) {
// stop checking for login
window.clearInterval(scanForLogin);
...
}
function onFailure (err) {
// stop checking for login
window.clearInterval(scanForLogin);
alert(err.message || err.Message);
}
What I ended up doing was to test for the presence of ESRI's Identity Manager Dialog using dojo/query, If the dialog was present, I hid the dialog and presented my own error message. Below I've added some code I used to search for this.
var scanForLogin;
arcgisUtils.createMap(agolId, mapDivId, { mapOptions: mapOptions })
.then(onSuccess, onFailure);
// check if a login is required.
require(["dojo/query", "dijit/registry"], function (dojoQuery, registry) {
var loginChecks = 0;
scanForLogin = window.setInterval(function () {
// testing access to sign in node
var signInNode = dojoQuery(".esriSignInDialog"),
promptDialog;
// if there is a signin node
if (signInNode.length) {
promptDialog = registry.byNode(signInNode[0]);
promptDialog.hide(); // hide the prompt dialog
onFailure({message: "Map failed to load properly"});
} else if (this.loginChecks > 4) {
// stops checking after five times (over 3 seconds).
window.clearInterval(this.scanForLogin);
}
loginChecks++;
}, 600);
});
function onSuccess (response) {
// stop checking for login
window.clearInterval(scanForLogin);
...
}
function onFailure (err) {
// stop checking for login
window.clearInterval(scanForLogin);
alert(err.message || err.Message);
}
Does anyone, (especially at ESRI), have a solution to this that doesn't require using a completely different build of the API or having an interval that hides the popup after the fact? Is there really no way to stop it? If our credentials expire or the layer cannot load for some other reason, we certainly don't want our users to get an ugly, clear popup that has absolutely no meaning to them (the users certainly don't have access to the username and password, heck, I don't even have access to them), we just want it to fail gracefully so we can show the user that the layer has failed and log it so someone who does have access to these things can fix it. It seems silly to show this login box by default, since the consumer of the layer (ostensibly me) and the consumer of the website (our clients) are completely different and showing this failure to properly authenticate on our part to our customers is very unprofessional. Is there a way to fix this?
Another option is to set the global reference to null in your first require callback using:
esri.id = null;