fix(desktop): corrige tela de desativacao duplicada no app Tauri
All checks were successful
CI/CD Web + Desktop / Detect changes (push) Successful in 10s
CI/CD Web + Desktop / Deploy (VPS Linux) (push) Successful in 3m38s
CI/CD Web + Desktop / Deploy Convex functions (push) Has been skipped
Quality Checks / Lint, Test and Build (push) Successful in 4m11s

- Adiciona verificacao de isMachineActive antes de redirecionar para handshake
- Remove mensagens de erro antigas com erro gramatical
- Corrige texto do template HTML de desativacao no servidor
- Corrige mensagem de erro na API de sessions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rever-tecnologia 2025-12-18 13:32:07 -03:00
parent 1a0574e7f4
commit f4a3b22aab
3 changed files with 12 additions and 14 deletions

View file

@ -1349,6 +1349,10 @@ const resolvedAppUrl = useMemo(() => {
const openSystem = useCallback(async () => { const openSystem = useCallback(async () => {
if (!token) return if (!token) return
if (!isMachineActive) {
setIsLaunchingSystem(false)
return
}
setIsLaunchingSystem(true) setIsLaunchingSystem(true)
// Recarrega store do disco para pegar dados que o Rust salvou diretamente // Recarrega store do disco para pegar dados que o Rust salvou diretamente
@ -1408,7 +1412,6 @@ const resolvedAppUrl = useMemo(() => {
setError(null) setError(null)
} }
if (!currentActive) { if (!currentActive) {
setError("Esta dispositivo está desativada. Entre em contato com o suporte da Rever para reativar o acesso.")
setIsLaunchingSystem(false) setIsLaunchingSystem(false)
return return
} }
@ -1416,14 +1419,8 @@ const resolvedAppUrl = useMemo(() => {
} }
} else { } else {
if (res.status === 423) { if (res.status === 423) {
const payload = await res.clone().json().catch(() => null)
const message =
payload && typeof payload === "object" && typeof (payload as { error?: unknown }).error === "string"
? ((payload as { error?: string }).error ?? "").trim()
: ""
setIsMachineActive(false) setIsMachineActive(false)
setIsLaunchingSystem(false) setIsLaunchingSystem(false)
setError(message.length > 0 ? message : "Esta dispositivo está desativada. Entre em contato com o suporte da Rever.")
return return
} }
// Se sessão falhar, tenta identificar token inválido/expirado // Se sessão falhar, tenta identificar token inválido/expirado
@ -1473,7 +1470,7 @@ const resolvedAppUrl = useMemo(() => {
const url = `${safeAppUrl}/machines/handshake?token=${encodeURIComponent(token)}&redirect=${encodeURIComponent(redirectTarget)}` const url = `${safeAppUrl}/machines/handshake?token=${encodeURIComponent(token)}&redirect=${encodeURIComponent(redirectTarget)}`
logDesktop("openSystem:redirect", { url: url.replace(/token=[^&]+/, "token=***") }) logDesktop("openSystem:redirect", { url: url.replace(/token=[^&]+/, "token=***") })
window.location.href = url window.location.href = url
}, [token, config?.accessRole, config?.machineId, resolvedAppUrl, store]) }, [token, config?.accessRole, config?.machineId, resolvedAppUrl, store, isMachineActive])
async function reprovision() { async function reprovision() {
if (!store) return if (!store) return
@ -1578,10 +1575,11 @@ const resolvedAppUrl = useMemo(() => {
if (!token) return if (!token) return
if (autoLaunchRef.current) return if (autoLaunchRef.current) return
if (!tokenVerifiedRef.current) return if (!tokenVerifiedRef.current) return
if (!isMachineActive) return // Não redireciona se a máquina estiver desativada
autoLaunchRef.current = true autoLaunchRef.current = true
setIsLaunchingSystem(true) setIsLaunchingSystem(true)
openSystem() openSystem()
}, [token, status, config?.accessRole, openSystem, tokenValidationTick]) }, [token, status, config?.accessRole, openSystem, tokenValidationTick, isMachineActive])
// Quando há token persistido (dispositivo já provisionado) e ainda não // Quando há token persistido (dispositivo já provisionado) e ainda não
// disparamos o auto-launch, exibimos diretamente a tela de loading da // disparamos o auto-launch, exibimos diretamente a tela de loading da

View file

@ -127,7 +127,7 @@ export async function POST(request: Request) {
} catch (error) { } catch (error) {
if (error instanceof MachineInactiveError) { if (error instanceof MachineInactiveError) {
return jsonWithCors( return jsonWithCors(
{ error: "Dispositivo desativada. Entre em contato com o suporte da Rever para reativar o acesso." }, { error: "Dispositivo desativado. Entre em contato com o suporte da Rever para reativar o acesso." },
423, 423,
origin, origin,
CORS_METHODS CORS_METHODS

View file

@ -9,7 +9,7 @@ const INACTIVE_TEMPLATE = `
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dispositivo desativada</title> <title>Dispositivo desativado</title>
<style> <style>
:root { color-scheme: dark light; } :root { color-scheme: dark light; }
body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background-color: #0f172a; color: #e2e8f0; margin: 0; display: grid; place-items: center; min-height: 100vh; padding: 24px; } body { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background-color: #0f172a; color: #e2e8f0; margin: 0; display: grid; place-items: center; min-height: 100vh; padding: 24px; }
@ -24,9 +24,9 @@ const INACTIVE_TEMPLATE = `
<body> <body>
<main> <main>
<div class="badge">Acesso bloqueado</div> <div class="badge">Acesso bloqueado</div>
<h1>Esta dispositivo está desativada</h1> <h1>Dispositivo desativado</h1>
<p>O acesso ao portal foi suspenso pelos administradores da Rever. Enquanto isso, você não poderá abrir chamados ou enviar atualizações.</p> <p>Este dispositivo foi desativado temporariamente pelos administradores. O acesso ao portal e o envio de informações ficam indisponíveis até a reativação.</p>
<p>Entre em contato com a equipe da Rever para solicitar a reativação desta dispositivo.</p> <p>Entre em contato com a equipe da Rever para solicitar a reativação deste dispositivo.</p>
<a href="mailto:suporte@rever.com.br">Falar com o suporte</a> <a href="mailto:suporte@rever.com.br">Falar com o suporte</a>
</main> </main>
</body> </body>