Use redirectUri for the Cordova adapter (#17038)

This commit is contained in:
Marco Schmidlin 2023-02-13 16:54:29 +01:00 committed by GitHub
parent 9d0bee9c59
commit 537be78455
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1418,6 +1418,8 @@ function Keycloak (config) {
return formatCordovaOptions(cordovaOptions);
};
var cordovaRedirectUri = kc.redirectUri || 'http://localhost';
return {
login: function(options) {
var promise = createPromise();
@ -1434,7 +1436,7 @@ function Keycloak (config) {
};
ref.addEventListener('loadstart', function(event) {
if (event.url.indexOf('http://localhost') == 0) {
if (event.url.indexOf(cordovaRedirectUri) == 0) {
var callback = parseCallback(event.url);
processCallback(callback, promise);
closeBrowser();
@ -1444,7 +1446,7 @@ function Keycloak (config) {
ref.addEventListener('loaderror', function(event) {
if (!completed) {
if (event.url.indexOf('http://localhost') == 0) {
if (event.url.indexOf(cordovaRedirectUri) == 0) {
var callback = parseCallback(event.url);
processCallback(callback, promise);
closeBrowser();
@ -1476,13 +1478,13 @@ function Keycloak (config) {
var error;
ref.addEventListener('loadstart', function(event) {
if (event.url.indexOf('http://localhost') == 0) {
if (event.url.indexOf(cordovaRedirectUri) == 0) {
ref.close();
}
});
ref.addEventListener('loaderror', function(event) {
if (event.url.indexOf('http://localhost') == 0) {
if (event.url.indexOf(cordovaRedirectUri) == 0) {
ref.close();
} else {
error = true;
@ -1508,7 +1510,7 @@ function Keycloak (config) {
var cordovaOptions = createCordovaOptions(options);
var ref = cordovaOpenWindowWrapper(registerUrl, '_blank', cordovaOptions);
ref.addEventListener('loadstart', function(event) {
if (event.url.indexOf('http://localhost') == 0) {
if (event.url.indexOf(cordovaRedirectUri) == 0) {
ref.close();
var oauth = parseCallback(event.url);
processCallback(oauth, promise);
@ -1522,7 +1524,7 @@ function Keycloak (config) {
if (typeof accountUrl !== 'undefined') {
var ref = cordovaOpenWindowWrapper(accountUrl, '_blank', 'location=no');
ref.addEventListener('loadstart', function(event) {
if (event.url.indexOf('http://localhost') == 0) {
if (event.url.indexOf(cordovaRedirectUri) == 0) {
ref.close();
}
});
@ -1532,7 +1534,7 @@ function Keycloak (config) {
},
redirectUri: function(options) {
return 'http://localhost';
return cordovaRedirectUri;
}
}
}