Z User commited on
Commit
df9d635
·
1 Parent(s): 44d212f

fix: remove old auth UI code that referenced non-existent header elements

Browse files

The old updateAuthUI() function in index.html tried to manipulate header elements
(authButtons, userMenu, mobileAccountBtn) that no longer exist since we replaced
the header with the new shared/navbar.html. Simplified to just set window.currentUser.

Files changed (1) hide show
  1. index.html +3 -35
index.html CHANGED
@@ -842,48 +842,16 @@
842
  }
843
 
844
  // ===== Auth Functions (via edge function) =====
 
 
845
  async function updateAuthUI() {
846
  try {
847
  const result = await window.EdgeFunctions.auth.checkSession();
848
  const user = result.user;
849
-
850
- const authButtons = document.getElementById('authButtons');
851
- const userMenu = document.getElementById('userMenu');
852
- const mobileAccountBtn = document.getElementById('mobileAccountBtn');
853
- const loggedInCheck = document.getElementById('loggedInCheck');
854
-
855
  if (user) {
856
  window.currentUser = user;
857
- authButtons.classList.add('hidden');
858
- userMenu.classList.remove('hidden');
859
- userMenu.classList.add('block');
860
-
861
- const fullName = user.user_metadata?.full_name ||
862
- user.user_metadata?.name ||
863
- user.email?.split('@')[0] || 'User';
864
- const firstName = fullName.split(' ')[0];
865
- const initial = firstName.charAt(0).toUpperCase();
866
-
867
- document.getElementById('userAvatar').textContent = initial;
868
- document.getElementById('avatarLarge').textContent = initial;
869
- document.getElementById('userFirstName').textContent = firstName;
870
-
871
- if (mobileAccountBtn) {
872
- mobileAccountBtn.href = 'profile.html';
873
- loggedInCheck.classList.remove('hidden');
874
- mobileAccountBtn.classList.add('text-green-600');
875
- mobileAccountBtn.classList.remove('text-gray-500');
876
- }
877
  } else {
878
- authButtons.classList.remove('hidden');
879
- userMenu.classList.add('hidden');
880
-
881
- if (mobileAccountBtn) {
882
- mobileAccountBtn.href = 'login.html';
883
- loggedInCheck.classList.add('hidden');
884
- mobileAccountBtn.classList.remove('text-green-600');
885
- mobileAccountBtn.classList.add('text-gray-500');
886
- }
887
  }
888
  } catch (error) {
889
  console.error('Auth error:', error);
 
842
  }
843
 
844
  // ===== Auth Functions (via edge function) =====
845
+ // The new shared/navbar.html handles its own auth UI, so we just
846
+ // set window.currentUser for the home page's use.
847
  async function updateAuthUI() {
848
  try {
849
  const result = await window.EdgeFunctions.auth.checkSession();
850
  const user = result.user;
 
 
 
 
 
 
851
  if (user) {
852
  window.currentUser = user;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853
  } else {
854
+ window.currentUser = null;
 
 
 
 
 
 
 
 
855
  }
856
  } catch (error) {
857
  console.error('Auth error:', error);