Skip to content
Snippets Groups Projects
Commit f77e7ffc authored by Gabriel Engel's avatar Gabriel Engel
Browse files

Merge pull request #3320 from ajwinter/develop

Fix CAS in Android Cordova
parents 1126ed85 ea4ff1e3
No related branches found
No related tags found
No related merge requests found
......@@ -40,29 +40,46 @@ Meteor.loginWithCas = function(options, callback) {
popup_height || 600
);
var checkPopupOpen = setInterval(function() {
var popupClosed;
try {
// Fix for #328 - added a second test criteria (popup.closed === undefined)
// to humour this Android quirk:
// http://code.google.com/p/android/issues/detail?id=21061
popupClosed = popup.closed || popup.closed === undefined;
} catch (e) {
// For some unknown reason, IE9 (and others?) sometimes (when
// the popup closes too quickly?) throws "SCRIPT16386: No such
// interface supported" when trying to read 'popup.closed'. Try
// again in 100ms.
return;
}
if (popupClosed) {
clearInterval(checkPopupOpen);
// Fix for #3200: monitor the popup differently if it's Cordova
if (Meteor.isCordova) {
// Check the URL when each page finishes loading, and if the URL contains "ticket", then close the popup because CAS has finished
popup.addEventListener('loadstop', function(e) {
if (e.url.indexOf('?ticket=') !== -1) {
popup.close();
}
});
popup.addEventListener('exit', function() {
// check auth on server.
Accounts.callLoginMethod({
methodArguments: [{ cas: { credentialToken: credentialToken } }],
userCallback: callback
});
}
}, 100);
});
} else {
var checkPopupOpen = setInterval(function() {
var popupClosed;
try {
// Fix for #328 - added a second test criteria (popup.closed === undefined)
// to humour this Android quirk:
// http://code.google.com/p/android/issues/detail?id=21061
popupClosed = popup.closed || popup.closed === undefined;
} catch (e) {
// For some unknown reason, IE9 (and others?) sometimes (when
// the popup closes too quickly?) throws "SCRIPT16386: No such
// interface supported" when trying to read 'popup.closed'. Try
// again in 100ms.
return;
}
if (popupClosed) {
clearInterval(checkPopupOpen);
// check auth on server.
Accounts.callLoginMethod({
methodArguments: [{ cas: { credentialToken: credentialToken } }],
userCallback: callback
});
}
}, 100);
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment