upgrade: modernização automatizada Logto_Supa

This commit is contained in:
2026-04-20 16:05:25 +00:00
parent ec1499e59c
commit d950384dad
7 changed files with 232 additions and 326 deletions

View File

@@ -1,3 +1,47 @@
// --- LOGTO AUTH GUARD ---
import LogtoClient from '@logto/browser';
// Escondemos o app imediatamente
const style = document.createElement('style');
style.innerHTML = 'body { display: none !important; }';
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'],
});
async function protectPage() {
const isCallback = window.location.pathname.includes('callback');
if (isCallback) {
try {
await logtoClient.handleSignInCallback(window.location.href);
window.location.assign('/');
} catch (error) {
console.error('Falha no callback do Logto:', error);
}
return;
}
const isAuthenticated = await logtoClient.isAuthenticated();
if (!isAuthenticated) {
await logtoClient.signIn(window.location.origin);
return;
}
// Se chegou aqui, está logado. Mostramos o app.
style.remove();
console.log('TSCUT: Acesso autorizado.');
}
// Execução imediata
protectPage();
// -------------------------
import * as XLSX from 'xlsx';
import Papa from 'papaparse';
import './style.css';