diff --git a/src/app/machines/auth-error/page.tsx b/src/app/machines/auth-error/page.tsx new file mode 100644 index 0000000..f3a70a6 --- /dev/null +++ b/src/app/machines/auth-error/page.tsx @@ -0,0 +1,48 @@ +import type { Metadata } from "next" +import Link from "next/link" + +import { Button } from "@/components/ui/button" + +export const metadata: Metadata = { + title: "Falha na autenticação da dispositivo", +} + +type AuthErrorPageProps = { + searchParams?: { + reason?: string + } +} + +export default function MachinesAuthErrorPage({ searchParams }: AuthErrorPageProps) { + const reason = (searchParams?.reason ?? "invalid_token").toString() + + const subtitle = + reason === "invalid_token" + ? "O token informado é inválido, expirou ou não está mais associado a uma dispositivo ativa." + : "Não foi possível autenticar esta dispositivo no momento. Tente novamente em instantes." + + return ( +
+
+
+ R +
+

+ Não foi possível autenticar esta dispositivo +

+

+ {subtitle} +

+

+ Volte ao Raven Desktop, reprovisione a dispositivo com um novo código ou tente novamente mais tarde. +

+
+ +
+
+
+ ) +} + diff --git a/src/app/machines/handshake/route.ts b/src/app/machines/handshake/route.ts index 0ea4258..4f25be4 100644 --- a/src/app/machines/handshake/route.ts +++ b/src/app/machines/handshake/route.ts @@ -3,33 +3,6 @@ import { NextRequest, NextResponse } from "next/server" import { createMachineSession, MachineInactiveError } from "@/server/machines-session" import { env } from "@/lib/env" -const ERROR_TEMPLATE = ` - - - - - - Falha na autenticação da dispositivo - - - -
-

Não foi possível autenticar esta dispositivo

-

O token informado é inválido, expirou ou não está mais associado a uma dispositivo ativa.

-

Volte ao agente desktop, gere um novo token ou realize o provisionamento novamente.

- Voltar para o Raven -
- - -` - const INACTIVE_TEMPLATE = ` @@ -163,11 +136,9 @@ export async function GET(request: NextRequest) { }) } console.error("[machines.handshake] Falha ao autenticar dispositivo", error) - return new NextResponse(ERROR_TEMPLATE, { - status: 500, - headers: { - "Content-Type": "text/html; charset=utf-8", - }, - }) + + const errorUrl = new URL("/machines/auth-error", request.nextUrl.origin) + errorUrl.searchParams.set("reason", "invalid_token") + return NextResponse.redirect(errorUrl) } }