Corrige redirect do portal após reset do dispositivo
All checks were successful
CI/CD Web + Desktop / Detect changes (push) Successful in 7s
CI/CD Web + Desktop / Deploy (VPS Linux) (push) Successful in 3m54s
CI/CD Web + Desktop / Deploy Convex functions (push) Has been skipped
Quality Checks / Lint, Test and Build (push) Successful in 4m31s

This commit is contained in:
rever-tecnologia 2025-12-18 15:29:08 -03:00
parent 84117e6821
commit 89f756e088

View file

@ -42,19 +42,13 @@ export function PortalShell({ children }: PortalShellProps) {
const handleTokenRevoked = useCallback(() => { const handleTokenRevoked = useCallback(() => {
console.log("[PortalShell] Token foi revogado - redirecionando para tela de registro") console.log("[PortalShell] Token foi revogado - redirecionando para tela de registro")
toast.error("Este dispositivo foi resetado. Faça login novamente.") toast.error("Este dispositivo foi resetado. Reprovisione para continuar.")
// Se estiver rodando dentro do Tauri, navega para a URL do app para voltar à tela de registro // Sessão "machine" existe apenas no fluxo do desktop; ao revogar o token, voltamos ao onboarding do app.
const isTauri = typeof window !== "undefined" && Boolean((window as typeof window & { __TAURI__?: unknown }).__TAURI__) const isDev = process.env.NODE_ENV === "development"
if (isTauri) { const tauriUrl = isDev ? "http://localhost:1420/" : "http://tauri.localhost/"
// URL do app Tauri - em producao usa tauri.localhost, em dev usa localhost:1420 console.log("[PortalShell] Redirecionando para o onboarding do desktop:", tauriUrl)
const isDev = process.env.NODE_ENV === "development" window.location.href = tauriUrl
const tauriUrl = isDev ? "http://localhost:1420/" : "http://tauri.localhost/" }, [])
console.log("[PortalShell] Detectado ambiente Tauri, navegando para:", tauriUrl)
window.location.href = tauriUrl
return
}
router.replace("/login")
}, [router])
const { isActive: machineIsActive } = useMachineStateMonitor({ const { isActive: machineIsActive } = useMachineStateMonitor({
machineId: machineContext?.machineId, machineId: machineContext?.machineId,