Commit 44ccbaab authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Now the login panel elements are rendered simultaneously.

parent d7f5502a
Pipeline #79118 skipped with stage
...@@ -13,31 +13,29 @@ var keycloak = new Keycloak({ ...@@ -13,31 +13,29 @@ var keycloak = new Keycloak({
realm: window.nomadEnv.keycloakRealm, realm: window.nomadEnv.keycloakRealm,
clientId: window.nomadEnv.keycloakClientId clientId: window.nomadEnv.keycloakClientId
}); });
let loginButton = document.querySelector('#login-button');
let logoutButton = document.querySelector('#logout-button');
let userName = document.querySelector('#user-name');
keycloak.init({ keycloak.init({
onLoad: "check-sso", onLoad: "check-sso",
silentCheckSsoRedirectUri: "http://localhost:3000/gui/silent-check-sso.html", silentCheckSsoRedirectUri: "http://localhost:3000/gui/silent-check-sso.html",
promiseType: "native", promiseType: "native",
}).then((authenticated) => { }).then((authenticated) => {
let loginButton = document.querySelector('#login-button');
let logoutButton = document.querySelector('#logout-button');
let userName = document.querySelector('#user-name');
if (authenticated) { if (authenticated) {
keycloak.loadUserProfile() keycloak.loadUserProfile()
.then(function(profile) { .then(function(profile) {
userName.textContent = `${profile.firstName} ${profile.lastName}`; userName.textContent = `${profile.firstName} ${profile.lastName}`;
loginButton.style.display = 'none';
logoutButton.style.display = 'inline';
}).catch(function() { }).catch(function() {
console.log('Failed to load user profile.'); console.log('Failed to load user profile.');
}); });
loginButton.style.display = 'none';
logoutButton.style.display = 'inline';
} else { } else {
loginButton.style.display = 'inline'; loginButton.style.display = 'inline';
logoutButton.style.display = 'none'; logoutButton.style.display = 'none';
userName.textContent = "Guest"; userName.textContent = "Guest";
} }
}); });
let loginButton = document.querySelector('#login-button');
let logoutButton = document.querySelector('#logout-button');
loginButton.onclick = () => { loginButton.onclick = () => {
keycloak.login({redirectUri: "http://" + window.location.host + "/gui/#/search"}) keycloak.login({redirectUri: "http://" + window.location.host + "/gui/#/search"})
.catch(() => {console.log("Authentication error.")}) .catch(() => {console.log("Authentication error.")})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment