From 47ea1ade8a1c9965c329bde52090e8e723a76349 Mon Sep 17 00:00:00 2001 From: Marko Strukelj Date: Mon, 1 May 2017 21:19:24 +0200 Subject: [PATCH] KEYCLOAK-4037 JS Adapter fails in Cordova mode for iOS apps --- adapters/oidc/js/src/main/resources/keycloak.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/adapters/oidc/js/src/main/resources/keycloak.js b/adapters/oidc/js/src/main/resources/keycloak.js index 3f09229a42..89b15b8a52 100755 --- a/adapters/oidc/js/src/main/resources/keycloak.js +++ b/adapters/oidc/js/src/main/resources/keycloak.js @@ -587,7 +587,7 @@ req.onreadystatechange = function () { if (req.readyState == 4) { - if (req.status == 200) { + if (req.status == 200 || fileLoaded(req)) { var config = JSON.parse(req.responseText); kc.authServerUrl = config['auth-server-url']; @@ -633,6 +633,10 @@ return promise.promise; } + function fileLoaded(xhr) { + return xhr.status == 0 && xhr.responseText && xhr.responseURL.startsWith('file:'); + } + function setToken(token, refreshToken, idToken, timeLocal) { if (kc.tokenTimeoutHandle) { clearTimeout(kc.tokenTimeoutHandle);