diff --git a/adapters/oidc/js/src/main/resources/keycloak.js b/adapters/oidc/js/src/main/resources/keycloak.js index 577452e634..c6adb9b67a 100755 --- a/adapters/oidc/js/src/main/resources/keycloak.js +++ b/adapters/oidc/js/src/main/resources/keycloak.js @@ -160,15 +160,25 @@ if (loginIframe.enable) { setupCheckLoginIframe().success(function() { checkLoginIframe().success(function () { + kc.onAuthSuccess && kc.onAuthSuccess(); initPromise.setSuccess(); }).error(function () { + kc.onAuthError && kc.onAuthError(); if (initOptions.onLoad) { onLoad(); } }); }); } else { - initPromise.setSuccess(); + kc.updateToken(-1).success(function() { + kc.onAuthSuccess && kc.onAuthSuccess(); + initPromise.setSuccess(); + }).error(function() { + kc.onAuthError && kc.onAuthError(); + if (initOptions.onLoad) { + onLoad(); + } + }); } } else if (initOptions.onLoad) { onLoad(); @@ -368,7 +378,7 @@ minValidity = minValidity || 5; var exec = function() { - if (!kc.isTokenExpired(minValidity)) { + if (minValidity >= 0 && !kc.isTokenExpired(minValidity)) { promise.setSuccess(false); } else { var params = 'grant_type=refresh_token&' + 'refresh_token=' + kc.refreshToken; @@ -1056,7 +1066,7 @@ if (!(this instanceof CookieStorage)) { return new CookieStorage(); } - + var cs = this; cs.get = function(state) {