KEYCLOAK-10910 login function now uses promise type specified in init

This commit is contained in:
jferrer 2019-07-23 11:28:40 +01:00 committed by Stan Silvert
parent b1be6c2bdd
commit 97fccd6d50

View file

@ -41,7 +41,7 @@
}
var useNonce = true;
kc.init = function (initOptions) {
kc.authenticated = false;
@ -154,11 +154,19 @@
if (!prompt) {
options.prompt = 'none';
}
kc.login(options).success(function () {
initPromise.setSuccess();
}).error(function () {
initPromise.setError();
});
if (kc.useNativePromise) {
kc.login(options).then(function () {
initPromise.setSuccess();
}).catch(function () {
initPromise.setError();
});
} else {
kc.login(options).success(function () {
initPromise.setSuccess();
}).error(function () {
initPromise.setError();
});
}
}
var checkSsoSilently = function() {
@ -388,7 +396,7 @@
if (options && options.locale) {
url += '&ui_locales=' + encodeURIComponent(options.locale);
}
if (options && options.kcLocale) {
url += '&kc_locale=' + encodeURIComponent(options.kcLocale);
}
@ -1320,7 +1328,7 @@
cordovaOptions.location = 'no';
if (userOptions && userOptions.prompt == 'none') {
cordovaOptions.hidden = 'yes';
}
}
return formatCordovaOptions(cordovaOptions);
};
@ -1332,7 +1340,7 @@
var loginUrl = kc.createLoginUrl(options);
var ref = cordovaOpenWindowWrapper(loginUrl, '_blank', cordovaOptions);
var completed = false;
var closed = false;
var closeBrowser = function() {
closed = true;
@ -1375,7 +1383,7 @@
logout: function(options) {
var promise = createPromise(false);
var logoutUrl = kc.createLogoutUrl(options);
var ref = cordovaOpenWindowWrapper(logoutUrl, '_blank', 'location=no,hidden=yes');