fix: explicit redirect URI and clean env
This commit is contained in:
80
.env
80
.env
@@ -1,83 +1,3 @@
|
|||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=b8dvrye4978k
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
|
||||||
VITE_SUPABASE_SCHEMA=TSCUT
|
|
||||||
|
|
||||||
# --- LOGTO_SUPA UPGRADE ---
|
|
||||||
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
VITE_LOGTO_ENDPOINT=https://logto-bzlued1boxl3t8ewsyn99an9.187.77.227.172.sslip.io
|
||||||
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
VITE_LOGTO_APP_ID=3whpc0jru4ka5nerinnuc
|
||||||
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
VITE_LOGTO_ORG_ID=4j7uhxlmia9e
|
||||||
|
|||||||
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-Bx_jQQRy.js"></script>
|
<script type="module" crossorigin src="/assets/index-DkgqtOrP.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-CpYIvPGq.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-CpYIvPGq.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
22
src/main.js
22
src/main.js
@@ -10,7 +10,6 @@ document.head.appendChild(style);
|
|||||||
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,
|
||||||
resource: 'https://default.logto.app/api',
|
|
||||||
scopes: ['openid', 'offline_access', 'profile', 'email', 'organizations'],
|
scopes: ['openid', 'offline_access', 'profile', 'email', 'organizations'],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -18,22 +17,36 @@ async function protectPage() {
|
|||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const isCallback = urlParams.has('code') && urlParams.has('state');
|
const isCallback = urlParams.has('code') && urlParams.has('state');
|
||||||
|
|
||||||
|
// Usar a origem exata sem assumir caminhos para evitar desvios no Logto
|
||||||
const exactRedirectUri = window.location.origin + '/';
|
const exactRedirectUri = window.location.origin + '/';
|
||||||
|
|
||||||
|
console.log('TSCUT Auth: Verificando estado...', { isCallback, origin: window.location.origin });
|
||||||
|
|
||||||
if (isCallback) {
|
if (isCallback) {
|
||||||
try {
|
try {
|
||||||
|
console.log('TSCUT Auth: Processando callback...', exactRedirectUri);
|
||||||
await logtoClient.handleSignInCallback(exactRedirectUri);
|
await logtoClient.handleSignInCallback(exactRedirectUri);
|
||||||
|
console.log('TSCUT Auth: Login bem sucedido!');
|
||||||
window.location.assign('/');
|
window.location.assign('/');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
style.remove();
|
style.remove();
|
||||||
document.body.innerHTML = `<div style="padding: 20px; color: red;"><h1>Erro de Autenticação Logto</h1><p>${error.message}</p></div>`;
|
document.body.innerHTML = `
|
||||||
|
<div style="padding: 20px; color: #ff5555; background: #1a1a1a; min-height: 100vh; font-family: sans-serif;">
|
||||||
|
<h1>Erro de Autenticação Logto</h1>
|
||||||
|
<p style="font-size: 1.2em;">${error.message}</p>
|
||||||
|
<hr style="border-color: #333;">
|
||||||
|
<p><strong>Dica:</strong> Se você estiver vendo "Missing state", verifique se os cookies e o armazenamento local estão habilitados para este site.</p>
|
||||||
|
<button onclick="window.location.assign('/')" style="padding: 10px 20px; cursor: pointer;">Tentar Novamente</button>
|
||||||
|
</div>`;
|
||||||
console.error('Falha no callback do Logto:', error);
|
console.error('Falha no callback do Logto:', error);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const isAuthenticated = await logtoClient.isAuthenticated();
|
const isAuthenticated = await logtoClient.isAuthenticated();
|
||||||
if (!isAuthenticated) {
|
if (!isAuthenticated) {
|
||||||
|
console.log('TSCUT Auth: Não autenticado. Redirecionando para login...');
|
||||||
await logtoClient.signIn(exactRedirectUri);
|
await logtoClient.signIn(exactRedirectUri);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,6 +54,11 @@ async function protectPage() {
|
|||||||
// Se chegou aqui, está logado. Mostramos o app.
|
// Se chegou aqui, está logado. Mostramos o app.
|
||||||
style.remove();
|
style.remove();
|
||||||
console.log('TSCUT: Acesso autorizado.');
|
console.log('TSCUT: Acesso autorizado.');
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Erro ao verificar autenticação:', err);
|
||||||
|
// Em caso de erro na verificação, tentamos o login novamente
|
||||||
|
await logtoClient.signIn(exactRedirectUri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execução imediata
|
// Execução imediata
|
||||||
|
|||||||
Reference in New Issue
Block a user