Enable custom css on login pages until a user with it disabled logs in.

This commit is contained in:
Ian Walton 2021-04-24 15:49:49 -04:00
parent b8f8633ffd
commit 99c902a1a1

View File

@ -217,30 +217,42 @@ function onAppReady() {
} }
} }
let cssHasLoadedTrigger;
const cssHasLoadedPromise = new Promise(resolve => {
cssHasLoadedTrigger = resolve;
});
const apiClient = ServerConnections.currentApiClient();
if (apiClient) {
fetch(apiClient.getUrl('Branding/Css'))
.then(function(response) {
if (!response.ok) {
throw new Error(response.status + ' ' + response.statusText);
}
return response.text();
})
.then(function(css) {
let style = document.querySelector('#cssBranding');
if (!style) {
// Inject the branding css as a dom element in body so it will take
// precedence over other stylesheets
style = document.createElement('style');
style.id = 'cssBranding';
document.body.appendChild(style);
}
style.textContent = css;
cssHasLoadedTrigger(style);
})
.catch(function(err) {
console.warn('Error applying custom css', err);
});
}
currentSettings.userIsSet().then(() => { currentSettings.userIsSet().then(() => {
const apiClient = ServerConnections.currentApiClient(); if (currentSettings.disableCustomCss()) {
if (apiClient && !currentSettings.disableCustomCss()) { cssHasLoadedPromise.then(style => {
fetch(apiClient.getUrl('Branding/Css')) style.textContent = '';
.then(function(response) { });
if (!response.ok) {
throw new Error(response.status + ' ' + response.statusText);
}
return response.text();
})
.then(function(css) {
let style = document.querySelector('#cssBranding');
if (!style) {
// Inject the branding css as a dom element in body so it will take
// precedence over other stylesheets
style = document.createElement('style');
style.id = 'cssBranding';
document.body.appendChild(style);
}
style.textContent = css;
})
.catch(function(err) {
console.warn('Error applying custom css', err);
});
} }
const localCss = currentSettings.customCss(); const localCss = currentSettings.customCss();