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

Function updateAuthenticatedUI

public/js/auth.js:340–493  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

338}
339
340export async function updateAuthenticatedUI(data) {
341 // Save latest auth data for later reuse
342 window.__lastAuthData = data;
343
344 // 1) Remove loading overlay safely
345 const loading = document.getElementById('loadingOverlay');
346 if (loading) loading.remove();
347
348 // 2) Show main UI
349 document.querySelector('.main-wrapper').style.display = '';
350 document.getElementById('loginForm').style.display = 'none';
351 toggleVisibility("loginForm", false);
352 toggleVisibility("mainOperations", true);
353 toggleVisibility("uploadFileForm", true);
354 toggleVisibility("fileListContainer", true);
355 if (typeof window.applyDualPaneMode === 'function') {
356 window.applyDualPaneMode();
357 }
358 attachEnterKeyListener("removeUserModal", "deleteUserBtn");
359 attachEnterKeyListener("changePasswordModal", "saveNewPasswordBtn");
360 document.querySelector(".header-buttons").style.visibility = "visible";
361
362 // 3) Persist auth flags (unchanged)
363 if (typeof data.totp_enabled !== "undefined") {
364 localStorage.setItem("userTOTPEnabled", data.totp_enabled ? "true" : "false");
365 }
366 if (data.username) {
367 localStorage.setItem("username", data.username);
368 }
369 if (typeof data.folderOnly !== "undefined") {
370 localStorage.setItem("folderOnly", data.folderOnly ? "true" : "false");
371 localStorage.setItem("readOnly", data.readOnly ? "true" : "false");
372 localStorage.setItem("disableUpload", data.disableUpload ? "true" : "false");
373 }
374
375 // 4) Fetch up-to-date profile picture — ALWAYS overwrite localStorage
376 const profilePicUrl = await fetchProfilePicture();
377 localStorage.setItem("profilePicUrl", profilePicUrl);
378
379 // 5) Build / update header buttons
380 const headerButtons = document.querySelector(".header-buttons");
381 const firstButton = headerButtons ? headerButtons.firstElementChild : null;
382
383 // c) user dropdown on non-demo
384{
385 let dd = document.getElementById("userDropdown");
386
387 // choose icon *or* img
388 const avatarHTML = profilePicUrl
389 ? `<img src="${profilePicUrl}" style="width:24px;height:24px;border-radius:50%;vertical-align:middle;">`
390 : `<i class="material-icons">account_circle</i>`;
391
392 // fallback username if missing
393 const usernameText = data.username
394 || localStorage.getItem("username")
395 || "";
396
397 if (!dd) {

Callers 2

checkAuthenticationFunction · 0.85
openUserPanelFunction · 0.85

Calls 13

toggleVisibilityFunction · 0.85
attachEnterKeyListenerFunction · 0.85
fetchProfilePictureFunction · 0.85
tFunction · 0.85
insertAfterFunction · 0.85
openUserPanelFunction · 0.85
openAdminPanelFunction · 0.85
openApiModalFunction · 0.85
triggerLogoutFunction · 0.85
initializeAppFunction · 0.85
applyTranslationsFunction · 0.85
updateItemsPerPageSelectFunction · 0.85

Tested by

no test coverage detected