Fix Nitro client launcher: read the nitro_path setting
The /client launcher read a non-existent `nitro_client_url` setting, so it
always fell through to "No client configured" and the client never launched.
Faithful to AtomCMS's NitroController + nitro.blade.php, build the launch URL
as {nitro_path}/index.html?sso=<ticket> plus the toolbar colour params, via a
shared buildNitroClientUrl helper. The Flash launcher's Nitro fallback used the
same dead key and is fixed too.
This commit is contained in:
1 parent
54ec99de6d
commit
56cd6fd058
4 files changed
+62
-26
No files matched your search
@@ -3,6 +3,7 @@ import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { ContentCard, EmptyState } from "@/components/public/ui";
|
||||
import { issueSsoTicket } from "@/lib/auth/sso-ticket";
|
||||
import { buildNitroClientUrl } from "@/lib/services/clients";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
@@ -14,17 +15,13 @@ export default async function FlashClientPage() {
|
||||
if (!session?.user?.id) redirect("/login");
|
||||
|
||||
const userId = Number(session.user.id);
|
||||
// The Flash client URL may be stored under either key depending on the
|
||||
// AtomCMS settings seed — try both, then fall back to the Nitro URL so the
|
||||
// launcher still issues a working SSO ticket.
|
||||
const [hotelName, flashUrl, flashUrlAlt, nitroUrl] = await Promise.all([
|
||||
// The Flash client base URL may be stored under either settings key.
|
||||
const [hotelNameRaw, flashUrl, flashUrlAlt] = await Promise.all([
|
||||
siteSettings.get("hotel_name", "Atom").catch(() => "Atom"),
|
||||
siteSettings.get("flash_client_url", "").catch(() => ""),
|
||||
siteSettings.get("client_flash_url", "").catch(() => ""),
|
||||
siteSettings.get("nitro_client_url", "").catch(() => ""),
|
||||
]);
|
||||
|
||||
const clientUrl = flashUrl || flashUrlAlt || nitroUrl || "";
|
||||
const hotelName = hotelNameRaw ?? "Atom";
|
||||
|
||||
const hdrs = await headers();
|
||||
const ip =
|
||||
@@ -32,11 +29,15 @@ export default async function FlashClientPage() {
|
||||
|
||||
// Faithful to AtomCMS's client controllers: issue (and persist) the SSO ticket
|
||||
// on the launcher render, then hand it to the Flash client.
|
||||
const ticket = await issueSsoTicket(prisma, userId, hotelName ?? "Atom", ip);
|
||||
const ticket = await issueSsoTicket(prisma, userId, hotelName, ip);
|
||||
|
||||
const src = clientUrl
|
||||
? `${clientUrl}${clientUrl.includes("?") ? "&" : "?"}sso=${encodeURIComponent(ticket)}`
|
||||
// Use a configured Flash base URL (with the SSO ticket appended); otherwise
|
||||
// fall back to the Nitro client so the launcher still works.
|
||||
const flashBase = flashUrl || flashUrlAlt || "";
|
||||
const flashSrc = flashBase
|
||||
? `${flashBase}${flashBase.includes("?") ? "&" : "?"}sso=${encodeURIComponent(ticket)}`
|
||||
: "";
|
||||
const src = flashSrc || (await buildNitroClientUrl(ticket));
|
||||
|
||||
return (
|
||||
<main style={{ display: "grid", gap: "1.5rem" }}>
|
||||
|
||||
+11
-15
@@ -3,6 +3,7 @@ import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { ContentCard, EmptyState } from "@/components/public/ui";
|
||||
import { issueSsoTicket } from "@/lib/auth/sso-ticket";
|
||||
import { buildNitroClientUrl } from "@/lib/services/clients";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
@@ -14,28 +15,22 @@ export default async function ClientPage() {
|
||||
if (!session?.user?.id) redirect("/login");
|
||||
|
||||
const userId = Number(session.user.id);
|
||||
const [hotelName, clientUrl] = await Promise.all([
|
||||
siteSettings.get("hotel_name", "Atom"),
|
||||
siteSettings.get("nitro_client_url", ""),
|
||||
]);
|
||||
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
|
||||
|
||||
const hdrs = await headers();
|
||||
const ip =
|
||||
hdrs.get("x-forwarded-for")?.split(",")[0]?.trim() ?? hdrs.get("x-real-ip") ?? "0.0.0.0";
|
||||
|
||||
// Faithful to AtomCMS's NitroController: issue (and persist) the SSO ticket on
|
||||
// the launcher render, then hand it to the client.
|
||||
const ticket = await issueSsoTicket(prisma, userId, hotelName ?? "Atom", ip);
|
||||
|
||||
const src = clientUrl
|
||||
? `${clientUrl}${clientUrl.includes("?") ? "&" : "?"}sso=${encodeURIComponent(ticket)}`
|
||||
: "";
|
||||
// the launcher render, then hand it to the Nitro client at {nitro_path}.
|
||||
const ticket = await issueSsoTicket(prisma, userId, hotelName, ip);
|
||||
const src = await buildNitroClientUrl(ticket);
|
||||
|
||||
return (
|
||||
<main style={{ display: "grid", gap: "1.5rem" }}>
|
||||
<ContentCard
|
||||
icon="🏨"
|
||||
title={`Launching ${hotelName ?? "Atom"}…`}
|
||||
title={`Launching ${hotelName}…`}
|
||||
subtitle="Your single sign-on ticket is ready"
|
||||
action={
|
||||
<Link href="/client/flash" className="btn btn-outline">
|
||||
@@ -49,14 +44,15 @@ export default async function ClientPage() {
|
||||
<iframe
|
||||
title="Hotel client"
|
||||
src={src}
|
||||
style={{ width: "100%", height: "80vh", border: 0, borderRadius: 10, display: "block" }}
|
||||
style={{ width: "100%", height: "85vh", border: 0, borderRadius: 10, display: "block" }}
|
||||
/>
|
||||
</ContentCard>
|
||||
) : (
|
||||
<ContentCard icon="🔌" title="No client configured" subtitle="Set nitro_client_url in settings">
|
||||
<ContentCard icon="🔌" title="No client configured" subtitle="Set nitro_path in settings">
|
||||
<EmptyState icon="🔌">
|
||||
No client URL configured (set <code>nitro_client_url</code> in settings). SSO ticket
|
||||
issued for this session: <code>{ticket}</code>
|
||||
No Nitro client configured — set <code>nitro_path</code> (e.g.{" "}
|
||||
<code>/Nitro-V3/dist</code>) in the admin settings. SSO ticket issued for this session:{" "}
|
||||
<code>{ticket}</code>
|
||||
</EmptyState>
|
||||
</ContentCard>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user