diff --git a/dist/index.html b/dist/index.html
index ee76abd..6491047 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 3ab7358..d26e39a 100644
--- a/src/main.js
+++ b/src/main.js
@@ -7,10 +7,20 @@ const style = document.createElement('style');
style.innerHTML = 'body { display: none !important; }';
document.head.appendChild(style);
+// Implementação de Storage Persistente para evitar perda de sessão em cross-domain
+const persistentStorage = {
+ getItem: (key) => localStorage.getItem(key),
+ setItem: (key, value) => {
+ try { localStorage.setItem(key, value); } catch (e) { console.error('Storage error', e); }
+ },
+ 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 // CRÍTICO: localStorage forçado
});
async function protectPage() {
@@ -22,21 +32,17 @@ async function protectPage() {
if (isCallback) {
try {
- // CRÍTICO: handleSignInCallback precisa da URL COMPLETA para extrair o ?code= e &state=
+ // Logto DEVE receber a URL completa com parâmetros para extrair o state
await logtoClient.handleSignInCallback(window.location.href);
-
- console.log('TSCUT Auth: Login bem sucedido!');
- // Limpa os parâmetros da URL para evitar erro no reload manual
- window.history.replaceState({}, document.title, redirectUri);
-
- style.remove();
+ console.log('TSCUT Auth: Login bem sucedido. Recarregando app...');
+ window.location.assign('/');
} catch (error) {
style.remove();
document.body.innerHTML = `
-
Falha na Autenticação
+
Falha na Autenticação Industrial
Erro: ${error.message}
-
`;
@@ -48,7 +54,7 @@ async function protectPage() {
try {
const isAuthenticated = await logtoClient.isAuthenticated();
if (!isAuthenticated) {
- console.log('TSCUT Auth: Não autenticado. Redirecionando...');
+ console.log('TSCUT Auth: Redirecionando para login Logto...');
await logtoClient.signIn(redirectUri);
return;
}