// frontend/static/js/common.js // Check authentication status and update the auth section (async function() { console.log('Checking authentication status...'); try { const response = await fetch('/api/auth/whoami'); const data = await response.json(); const authSection = document.getElementById("authSection"); const mobileAuthSection = document.getElementById("mobileAuthSection"); // If we have an email, user is authenticated (the whoami endpoint would have thrown 401 otherwise) if (data.email) { // Get the display name (prefer name, fall back to preferred_username, then email) const displayName = data.name || data.preferred_username || data.email; // User is logged in let authHTML = `
`; if (authSection) { authSection.innerHTML = authHTML; } if (mobileAuthSection) { mobileAuthSection.innerHTML = `