diff --git a/dist/index.html b/dist/index.html index 7cbcdd3..71bd39a 100644 --- a/dist/index.html +++ b/dist/index.html @@ -6,7 +6,7 @@ Otimizador de Corte - TSCUT - + diff --git a/src/main.js b/src/main.js index baf58fa..ed621fa 100644 --- a/src/main.js +++ b/src/main.js @@ -7,10 +7,18 @@ const style = document.createElement('style'); style.innerHTML = 'body { display: none !important; }'; document.head.appendChild(style); +// Implementação de Storage Persistente para evitar perdas em redirecionamentos +const persistentStorage = { + getItem: (key) => localStorage.getItem(key), + setItem: (key, value) => localStorage.setItem(key, value), + removeItem: (key) => localStorage.removeItem(key), +}; + const logtoClient = new LogtoClient({ endpoint: import.meta.env.VITE_LOGTO_ENDPOINT, appId: import.meta.env.VITE_LOGTO_APP_ID, scopes: ['openid', 'offline_access', 'profile', 'email', 'organizations'], + storage: persistentStorage, // Força o uso de localStorage }); async function protectPage() { @@ -23,7 +31,7 @@ async function protectPage() { console.log('TSCUT Auth: Inicializando...', { isCallback, href: window.location.href, - storageKeys: Object.keys(sessionStorage).filter(k => k.includes('logto')) + storageKeys: Object.keys(localStorage).filter(k => k.includes('logto')) }); if (isCallback) { @@ -38,7 +46,7 @@ async function protectPage() { window.location.assign('/'); } catch (error) { style.remove(); - const logtoState = sessionStorage.getItem(`logto:${import.meta.env.VITE_LOGTO_APP_ID}:state`); + const logtoState = localStorage.getItem(`logto:${import.meta.env.VITE_LOGTO_APP_ID}:state`); document.body.innerHTML = `