Redirect to login form automatically in keycloak.js if login-required is set

This commit is contained in:
Stian Thorgersen 2014-05-22 16:59:38 +01:00
parent 08b1996149
commit de36973716

View file

@ -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();
}
}
}