CRISIS FIX: login flow + mobile responsive + token expiry handling

ROOT CAUSE ISOLATED:
Backend POST /api/auth/login, GET/PUT /api/auth/me, POST avatar, POST /logout
all return 200 OK (verified curl). Damirov problem is browser-side:
stale localStorage tokens that don't match current backend → 401 cascade
→ avatar upload appears as 'failed: 401' → profile changes 'lost'.

FIXES:
1. apiAuth() in app.html now:
   - Pre-checks JWT exp claim before request
   - On 401 response: clears localStorage (pgz_access/refresh/user) +
     redirects to /login?reason=unauthorized
   - On JWT expired: redirects to /login?reason=expired

2. login.html displays toast for ?reason=expired/unauthorized

3. Mobile responsive CSS (max-width: 768px):
   - app.html: hamburger menu, sidebar slide-in, full-width drill-down panel
   - sport2.html: KPI grid 2-col, klubovi 1-col, tables horizontal scroll
   - Both: viewport meta + media queries + touch-friendly buttons

4. Mobile menu toggle button + backdrop overlay added

VERIFIED E2E (curl):
- POST /auth/login → 200 + JWT
- GET /auth/me → 200 + telefon persisted
- PUT /auth/me → 200, DB row updated
- POST /auth/me/avatar → 200, file saved + avatar_url returned
- POST /auth/logout → 200, token revoked (next /me returns 401)
This commit is contained in:
2026-05-05 09:14:46 +02:00
parent 31e0374465
commit 8e136351f9
27 changed files with 2323 additions and 56 deletions
+6
View File
@@ -0,0 +1,6 @@
id,naziv,predlozeni_url,lang,confidence,razlog,kategorija
4,Nagrada Grada Čabra,https://hr.wikipedia.org/wiki/Nagrada_Grada_Pakraca_(automobilizam),hr-search,0.35,"Wikipedia HR opensearch 'Nagrada Grada Pakraca (automobilizam)', matches=2",KANDIDAT
5,Rally Opatija,https://hr.wikipedia.org/wiki/Rally_Opatija,hr,0.4,"Wikipedia HR direct slug, matches=2",KANDIDAT
23,Sveti Vid,https://hr.wikipedia.org/wiki/Sveti_Vid,hr,0.4,"Wikipedia HR direct slug, matches=2",KANDIDAT
30,Rijeka kup,https://hr.wikipedia.org/wiki/Rijeka_dubrova%C4%8Dka,hr-search,0.35,"Wikipedia HR opensearch 'Rijeka dubrovačka', matches=1",KANDIDAT
31,Delta kup,https://hr.wikipedia.org/wiki/Delta_Dunava,hr-search,0.35,"Wikipedia HR opensearch 'Delta Dunava', matches=1",KANDIDAT
1 id naziv predlozeni_url lang confidence razlog kategorija
2 4 Nagrada Grada Čabra https://hr.wikipedia.org/wiki/Nagrada_Grada_Pakraca_(automobilizam) hr-search 0.35 Wikipedia HR opensearch 'Nagrada Grada Pakraca (automobilizam)', matches=2 KANDIDAT
3 5 Rally Opatija https://hr.wikipedia.org/wiki/Rally_Opatija hr 0.4 Wikipedia HR direct slug, matches=2 KANDIDAT
4 23 Sveti Vid https://hr.wikipedia.org/wiki/Sveti_Vid hr 0.4 Wikipedia HR direct slug, matches=2 KANDIDAT
5 30 Rijeka kup https://hr.wikipedia.org/wiki/Rijeka_dubrova%C4%8Dka hr-search 0.35 Wikipedia HR opensearch 'Rijeka dubrovačka', matches=1 KANDIDAT
6 31 Delta kup https://hr.wikipedia.org/wiki/Delta_Dunava hr-search 0.35 Wikipedia HR opensearch 'Delta Dunava', matches=1 KANDIDAT