From de36973716d62fde7a8c92786b3d4f092e464438 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 22 May 2014 16:59:38 +0100 Subject: [PATCH] Redirect to login form automatically in keycloak.js if login-required is set --- integration/js/src/main/resources/keycloak.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/integration/js/src/main/resources/keycloak.js b/integration/js/src/main/resources/keycloak.js index b05761d850..84ae29c09a 100755 --- a/integration/js/src/main/resources/keycloak.js +++ b/integration/js/src/main/resources/keycloak.js @@ -29,6 +29,10 @@ var Keycloak = function (config) { if (initOptions.checkLoginIframeInterval) { loginIframe.interval = initOptions.checkLoginIframeInterval; } + + if (initOptions.onLoad === 'login-required') { + kc.loginRequired = true; + } } var promise = createPromise(); @@ -374,6 +378,9 @@ var Keycloak = function (config) { if (kc.token) { setToken(null, null); kc.onAuthLogout && kc.onAuthLogout(); + if (kc.loginRequired) { + kc.login(); + } } }