import { Hono } from "hono"; import Config from "../../../config/peas.config.js"; import type InfoAPI from "../../../types/api/info"; import { Layout } from "./layout.js"; import { Locale } from "../../lib/locale.js"; import Icon from "../../components/iconify.js"; import { getKeys as getTurnstileKeys, isEnabled as TurnstileIsEnabled } from "../../lib/turnstile.js"; import Turnstile from "../../components/turnstile.js"; import { html } from "hono/html"; import { getCookie } from "hono/cookie"; import { isSignin } from "../../lib/token.js"; const MailVerify = new Hono(); MailVerify.get("/", async (c) => { if (await isSignin(getCookie(c, "token") ?? "")) { return c.redirect("/home"); } const InfoReq = await fetch(`${Config.server.origin}/api/info`, { method: "POST", cache: "no-store", }); if (!InfoReq.ok) { return c.status(500); } const InfoRes: InfoAPI = await InfoReq.json(); let code = ""; if (c.req.query("code") !== undefined) { code = c.req.query("code") ?? ""; } const TurnstileEnabled = await TurnstileIsEnabled(); let TurnstileKeys: Array = []; if (TurnstileEnabled) { TurnstileKeys = await getTurnstileKeys(); } let error = false; let errorMsg = ""; if (c.req.query("error") !== undefined) { error = true; errorMsg = Locale({ text: `ERR_${c.req.query("error")}` }, c.get("language")); } return c.html(
{error && ( )}

{Locale({ text: "mailVerify" }, c.get("language"))}

{TurnstileEnabled && ( )}