// ===== Main SPA Router ===== const App = { topicsCache: null, _hashListenerAttached: false, async init(skipValidation) { if (!Auth.getToken()) { this.showLogin(); return; } // Skip server validation when called right after login (token is fresh) if (!skipValidation) { try { const res = await fetch('/api/auth/me', { headers: Auth.headers() }); if (!res.ok) throw new Error('Token invalid'); } catch (e) { Auth.clearSession(); this.showLogin(); return; } } // Protection.init() must never break the app try { Protection.init(); } catch(e) { console.warn('[App] Protection.init error:', e); } try { Heartbeat.init(); } catch(e) { console.warn('[App] Heartbeat.init error:', e); } this.renderHeader(); this.handleRoute(); if (!this._hashListenerAttached) { this._hashListenerAttached = true; window.addEventListener('hashchange', () => this.handleRoute()); } }, showLogin() { document.getElementById('app').innerHTML = `
${this.escapeHtml(e.message)}
Nenhuma questao respondida ainda. Comece respondendo questoes para ver suas estatisticas!
'; } html += '${this.escapeHtml(e.message)}
Informe seu email para receber o codigo de verificacao.
Digite o codigo de 6 digitos enviado para seu email.
Escolha sua nova senha.