MCPcopy Create free account
hub / github.com/error311/FileRise / loadAdminConfigFunc

Function loadAdminConfigFunc

public/js/auth.js:266–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

264}
265
266export function loadAdminConfigFunc() {
267 if (window.__FR_SITE_CFG_PROMISE) return window.__FR_SITE_CFG_PROMISE;
268 window.__FR_SITE_CFG_PROMISE = fetch("/api/public/siteConfig.php", { credentials: "include" })
269 .then(async (response) => {
270 // If a proxy or some edge returns 204/empty, handle gracefully
271 let config = {};
272 try { config = await response.json(); } catch (e) { config = {}; }
273
274 const isPro = !!(config.pro && config.pro.active);
275 const headerTitle = resolveHeaderTitle(config.header_title, isPro);
276 localStorage.setItem("headerTitle", headerTitle);
277
278 document.title = headerTitle;
279 const lo = config.loginOptions || {};
280 localStorage.setItem("disableFormLogin", String(!!lo.disableFormLogin));
281 localStorage.setItem("disableBasicAuth", String(!!lo.disableBasicAuth));
282 localStorage.setItem("disableOIDCLogin", String(!!lo.disableOIDCLogin));
283 localStorage.setItem("globalOtpauthUrl", config.globalOtpauthUrl || "otpauth://totp/{label}?secret={secret}&issuer=FileRise");
284 // These may be absent for non-admins; default them
285 localStorage.setItem("authBypass", String(!!lo.authBypass));
286 localStorage.setItem("authHeaderName", lo.authHeaderName || "X-Remote-User");
287
288 updateLoginOptionsUIFromStorage();
289
290 const headerTitleElem = document.querySelector(".header-title h1");
291 if (headerTitleElem) headerTitleElem.textContent = headerTitle;
292 })
293 .catch(() => {
294 // Fallback defaults if request truly fails
295 const fallbackTitle = resolveHeaderTitle(
296 DEFAULT_HEADER_TITLE,
297 window.__FR_IS_PRO === true
298 );
299 localStorage.setItem("headerTitle", fallbackTitle);
300 localStorage.setItem("disableFormLogin", "false");
301 localStorage.setItem("disableBasicAuth", "false");
302 localStorage.setItem("disableOIDCLogin", "false");
303 localStorage.setItem("globalOtpauthUrl", "otpauth://totp/{label}?secret={secret}&issuer=FileRise");
304 updateLoginOptionsUIFromStorage();
305
306 const headerTitleElem = document.querySelector(".header-title h1");
307 if (headerTitleElem) headerTitleElem.textContent = fallbackTitle;
308 document.title = fallbackTitle;
309 })
310 .finally(() => { window.__FR_SITE_CFG_PROMISE = null; });
311 return window.__FR_SITE_CFG_PROMISE;
312}
313
314function insertAfter(newNode, referenceNode) {
315 referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);

Callers 4

initProBundleInstallerFunction · 0.85
openAdminPanelFunction · 0.85
initAuthFunction · 0.85
initializeAppFunction · 0.85

Calls 2

resolveHeaderTitleFunction · 0.70

Tested by

no test coverage detected