Javascript Adapter - Reject 'login' promise when users close their cordova in-app-browser on purpose (#5000)
This commit is contained in:
parent
1258923a0d
commit
27d8afe4a7
1 changed files with 17 additions and 3 deletions
|
@ -1224,11 +1224,17 @@
|
|||
var ref = cordovaOpenWindowWrapper(loginUrl, '_blank', cordovaOptions);
|
||||
var completed = false;
|
||||
|
||||
var closed = false;
|
||||
var closeBrowser = function() {
|
||||
closed = true;
|
||||
ref.close();
|
||||
};
|
||||
|
||||
ref.addEventListener('loadstart', function(event) {
|
||||
if (event.url.indexOf('http://localhost') == 0) {
|
||||
var callback = parseCallback(event.url);
|
||||
processCallback(callback, promise);
|
||||
ref.close();
|
||||
closeBrowser();
|
||||
completed = true;
|
||||
}
|
||||
});
|
||||
|
@ -1238,15 +1244,23 @@
|
|||
if (event.url.indexOf('http://localhost') == 0) {
|
||||
var callback = parseCallback(event.url);
|
||||
processCallback(callback, promise);
|
||||
ref.close();
|
||||
closeBrowser();
|
||||
completed = true;
|
||||
} else {
|
||||
promise.setError();
|
||||
ref.close();
|
||||
closeBrowser();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ref.addEventListener('exit', function(event) {
|
||||
if (!closed) {
|
||||
promise.setError({
|
||||
reason: "closed_by_user"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return promise.promise;
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue