diff --git a/VERSION b/VERSION index 1c1c657..825e329 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1168 \ No newline at end of file +1169 \ No newline at end of file diff --git a/backend/static/index.html b/backend/static/index.html index 924cf5d..df9c4ba 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 3dd65cf..1c46941 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1168'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1169'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; @@ -1116,11 +1116,15 @@ const App = (() => { sessionStorage.setItem('by_stay_in_app', '1'); } - // Referral-Code aus URL ?ref=CODE speichern + // Referral-Code aus URL ?ref=CODE speichern (Backup zu boot.js; localStorage + // überlebt App-Schließen, sodass die Zuordnung auch bei späterer Registrierung klappt) const urlParams = new URLSearchParams(window.location.search); const refCode = urlParams.get('ref'); if (refCode) { - sessionStorage.setItem('by_ref_code', refCode.toUpperCase()); + try { + localStorage.setItem('by_ref_code', refCode.toUpperCase()); + localStorage.setItem('by_ref_code_ts', String(Date.now())); + } catch {} // URL bereinigen ohne Reload history.replaceState({}, '', window.location.pathname + window.location.hash); } diff --git a/backend/static/js/boot.js b/backend/static/js/boot.js index 50d5352..26e5df5 100644 --- a/backend/static/js/boot.js +++ b/backend/static/js/boot.js @@ -4,6 +4,22 @@ Extrahiert aus index.html für CSP-Härtung (kein unsafe-inline) ============================================================ */ +// ---------------------------------------------------------- +// Referral-Code aus ?ref= SOFORT in localStorage sichern — so früh wie möglich, +// bevor ein SW-Update-Reload die URL durch /?_t=... ersetzt und den Code verliert. +// localStorage (statt sessionStorage) überlebt auch App-Schließen/PWA-Neustart, +// sodass die Zuordnung auch klappt, wenn sich die Person erst später registriert. +// ---------------------------------------------------------- +(function() { + try { + var rc = new URLSearchParams(location.search).get('ref'); + if (rc) { + localStorage.setItem('by_ref_code', rc.toUpperCase()); + localStorage.setItem('by_ref_code_ts', String(Date.now())); + } + } catch (e) {} +})(); + // ---------------------------------------------------------- // Offline-Banner // ---------------------------------------------------------- diff --git a/backend/static/js/pages/settings.js b/backend/static/js/pages/settings.js index e959070..e59aaeb 100644 --- a/backend/static/js/pages/settings.js +++ b/backend/static/js/pages/settings.js @@ -2485,13 +2485,27 @@ window.Page_settings = (() => { }); } + // Referral-Code aus localStorage lesen (30-Tage-Ablauf) bzw. löschen. + const _storedRefCode = () => { + try { + const code = localStorage.getItem('by_ref_code') || ''; + if (!code) return ''; + const ts = parseInt(localStorage.getItem('by_ref_code_ts') || '0', 10); + if (ts && Date.now() - ts > 30 * 24 * 3600 * 1000) { _clearRefCode(); return ''; } + return code; + } catch { return ''; } + }; + const _clearRefCode = () => { + try { localStorage.removeItem('by_ref_code'); localStorage.removeItem('by_ref_code_ts'); } catch {} + }; + // Partner-Code live validieren const partnerInput = document.getElementById('reg-partner-code'); const partnerHint = document.getElementById('reg-partner-hint'); let _partnerValid = false; if (partnerInput) { - // Vorausfüllen falls via sessionStorage gesetzt - const stored = sessionStorage.getItem('by_ref_code') || ''; + // Vorausfüllen falls via Referral-Link gesetzt (localStorage, überlebt App-Schließen) + const stored = _storedRefCode(); if (stored) partnerInput.value = stored; let _debounce = null; @@ -2539,10 +2553,10 @@ window.Page_settings = (() => { await UI.asyncButton(btn, async () => { const partnerCode = (fd.partner_code || '').trim().toUpperCase() || undefined; - const refCode = sessionStorage.getItem('by_ref_code') || ''; + const refCode = _storedRefCode(); const finalCode = partnerCode || refCode || undefined; const result = await API.auth.register(fd.email, fd.password, fd.name.trim(), finalCode); - if (refCode) sessionStorage.removeItem('by_ref_code'); + if (refCode) _clearRefCode(); if (result.pending_verification) { _renderVerifyPending(fd.email); diff --git a/backend/static/landing.html b/backend/static/landing.html index cf8aba3..22f5926 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 003c599..ee5d283 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1168'; +const VER = '1169'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten