diff --git a/common/js/keycloak.js b/common/js/keycloak.js index b26629d..754e00a 100644 --- a/common/js/keycloak.js +++ b/common/js/keycloak.js @@ -442,16 +442,14 @@ baseUrl = kc.endpoints.authorize(); } - var scope; - if (options && options.scope || kc.scope) { - if (options.scope.indexOf("openid") != -1) { - scope = options.scope; - } else { - scope = "openid " + options.scope; - } - } else { - scope = "openid"; - } + var scope = options && options.scope || kc.scope; + if (!scope) { + // if scope is not set, default to "openid" + scope = "openid"; + } else if (scope.indexOf("openid") === -1) { + // if openid scope is missing, prefix the given scopes with it + scope = "openid " + scope; + } var url = baseUrl + '?client_id=' + encodeURIComponent(kc.clientId)