fix: force localStorage for Logto persistence
This commit is contained in:
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" href="/logo.png" type="image/png">
|
<link rel="icon" href="/logo.png" type="image/png">
|
||||||
<title>Otimizador de Corte - TSCUT</title>
|
<title>Otimizador de Corte - TSCUT</title>
|
||||||
<script type="module" crossorigin src="/assets/index-DBmQnaAQ.js"></script>
|
<script type="module" crossorigin src="/assets/index-B7sXKXk5.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-CpYIvPGq.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-CpYIvPGq.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
12
src/main.js
12
src/main.js
@@ -7,10 +7,18 @@ const style = document.createElement('style');
|
|||||||
style.innerHTML = 'body { display: none !important; }';
|
style.innerHTML = 'body { display: none !important; }';
|
||||||
document.head.appendChild(style);
|
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({
|
const logtoClient = new LogtoClient({
|
||||||
endpoint: import.meta.env.VITE_LOGTO_ENDPOINT,
|
endpoint: import.meta.env.VITE_LOGTO_ENDPOINT,
|
||||||
appId: import.meta.env.VITE_LOGTO_APP_ID,
|
appId: import.meta.env.VITE_LOGTO_APP_ID,
|
||||||
scopes: ['openid', 'offline_access', 'profile', 'email', 'organizations'],
|
scopes: ['openid', 'offline_access', 'profile', 'email', 'organizations'],
|
||||||
|
storage: persistentStorage, // Força o uso de localStorage
|
||||||
});
|
});
|
||||||
|
|
||||||
async function protectPage() {
|
async function protectPage() {
|
||||||
@@ -23,7 +31,7 @@ async function protectPage() {
|
|||||||
console.log('TSCUT Auth: Inicializando...', {
|
console.log('TSCUT Auth: Inicializando...', {
|
||||||
isCallback,
|
isCallback,
|
||||||
href: window.location.href,
|
href: window.location.href,
|
||||||
storageKeys: Object.keys(sessionStorage).filter(k => k.includes('logto'))
|
storageKeys: Object.keys(localStorage).filter(k => k.includes('logto'))
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isCallback) {
|
if (isCallback) {
|
||||||
@@ -38,7 +46,7 @@ async function protectPage() {
|
|||||||
window.location.assign('/');
|
window.location.assign('/');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
style.remove();
|
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 = `
|
document.body.innerHTML = `
|
||||||
<div style="padding: 20px; color: #ff5555; background: #1a1a1a; min-height: 100vh; font-family: sans-serif;">
|
<div style="padding: 20px; color: #ff5555; background: #1a1a1a; min-height: 100vh; font-family: sans-serif;">
|
||||||
|
|||||||
Reference in New Issue
Block a user