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_APP_ID=3whpc0jru4ka5nerinnuc
|
||||
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">
|
||||
<link rel="icon" href="/logo.png" type="image/png">
|
||||
<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">
|
||||
</head>
|
||||
|
||||
|
||||
38
src/main.js
38
src/main.js
@@ -10,7 +10,6 @@ document.head.appendChild(style);
|
||||
const logtoClient = new LogtoClient({
|
||||
endpoint: import.meta.env.VITE_LOGTO_ENDPOINT,
|
||||
appId: import.meta.env.VITE_LOGTO_APP_ID,
|
||||
resource: 'https://default.logto.app/api',
|
||||
scopes: ['openid', 'offline_access', 'profile', 'email', 'organizations'],
|
||||
});
|
||||
|
||||
@@ -18,29 +17,48 @@ async function protectPage() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
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 + '/';
|
||||
|
||||
console.log('TSCUT Auth: Verificando estado...', { isCallback, origin: window.location.origin });
|
||||
|
||||
if (isCallback) {
|
||||
try {
|
||||
console.log('TSCUT Auth: Processando callback...', exactRedirectUri);
|
||||
await logtoClient.handleSignInCallback(exactRedirectUri);
|
||||
console.log('TSCUT Auth: Login bem sucedido!');
|
||||
window.location.assign('/');
|
||||
} catch (error) {
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const isAuthenticated = await logtoClient.isAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
await logtoClient.signIn(exactRedirectUri);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const isAuthenticated = await logtoClient.isAuthenticated();
|
||||
if (!isAuthenticated) {
|
||||
console.log('TSCUT Auth: Não autenticado. Redirecionando para login...');
|
||||
await logtoClient.signIn(exactRedirectUri);
|
||||
return;
|
||||
}
|
||||
|
||||
// Se chegou aqui, está logado. Mostramos o app.
|
||||
style.remove();
|
||||
console.log('TSCUT: Acesso autorizado.');
|
||||
// Se chegou aqui, está logado. Mostramos o app.
|
||||
style.remove();
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user