From 7b19979118fc491e24e81024bc0e5ea524d0052a Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Sun, 1 Feb 2026 09:38:36 -0800 Subject: [PATCH] Show user's first initial in profile avatar instead of hardcoded U Save FirstName to localStorage on login (both OTP and password paths). Portal reads it back and displays the first letter in the user avatar. Falls back to 'U' if no name is stored. Cleared on logout. Co-Authored-By: Claude Opus 4.5 --- portal/login.html | 5 +++++ portal/portal.js | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/portal/login.html b/portal/login.html index 9f785a0..94af0a2 100644 --- a/portal/login.html +++ b/portal/login.html @@ -507,6 +507,8 @@ localStorage.setItem('payfrit_portal_token', token); localStorage.setItem('payfrit_portal_userid', userId); + const firstName = data.FIRSTNAME || data.FirstName || ''; + if (firstName) localStorage.setItem('payfrit_portal_firstname', firstName); await this.loadBusinesses(); @@ -629,6 +631,8 @@ localStorage.setItem('payfrit_portal_token', token); localStorage.setItem('payfrit_portal_userid', userId); + const firstName = data.FirstName || data.FIRSTNAME || ''; + if (firstName) localStorage.setItem('payfrit_portal_firstname', firstName); await this.loadBusinesses(); @@ -760,6 +764,7 @@ localStorage.removeItem('payfrit_portal_token'); localStorage.removeItem('payfrit_portal_userid'); localStorage.removeItem('payfrit_portal_business'); + localStorage.removeItem('payfrit_portal_firstname'); window.location.href = BASE_PATH + '/portal/login.html'; } }; diff --git a/portal/portal.js b/portal/portal.js index 665a09e..8045ae2 100644 --- a/portal/portal.js +++ b/portal/portal.js @@ -113,18 +113,18 @@ const Portal = { this.businessData = biz; // Store for later use document.getElementById('businessName').textContent = biz.Name || 'Business'; document.getElementById('businessAvatar').textContent = (biz.Name || 'B').charAt(0).toUpperCase(); - document.getElementById('userAvatar').textContent = 'U'; + document.getElementById('userAvatar').textContent = (localStorage.getItem('payfrit_portal_firstname') || 'U').charAt(0).toUpperCase(); } else { this.businessData = null; document.getElementById('businessName').textContent = 'Business #' + this.config.businessId; document.getElementById('businessAvatar').textContent = 'B'; - document.getElementById('userAvatar').textContent = 'U'; + document.getElementById('userAvatar').textContent = (localStorage.getItem('payfrit_portal_firstname') || 'U').charAt(0).toUpperCase(); } } catch (err) { console.error('[Portal] Business info error:', err); document.getElementById('businessName').textContent = 'Business #' + this.config.businessId; document.getElementById('businessAvatar').textContent = 'B'; - document.getElementById('userAvatar').textContent = 'U'; + document.getElementById('userAvatar').textContent = (localStorage.getItem('payfrit_portal_firstname') || 'U').charAt(0).toUpperCase(); } }, @@ -151,6 +151,7 @@ const Portal = { localStorage.removeItem('payfrit_portal_token'); localStorage.removeItem('payfrit_portal_userid'); localStorage.removeItem('payfrit_portal_business'); + localStorage.removeItem('payfrit_portal_firstname'); window.location.href = BASE_PATH + '/portal/login.html'; },