diff --git a/app/app/lib/auth.server.ts b/app/app/lib/auth.server.ts index 54b3e69..c485436 100644 --- a/app/app/lib/auth.server.ts +++ b/app/app/lib/auth.server.ts @@ -90,7 +90,7 @@ export function requireAdmin(request: Request): AdminSession { if (!session) { const url = new URL(request.url); const next = `${url.pathname}${url.search}`; - throw redirect(`/admin/login?next=${encodeURIComponent(next)}`); + throw redirect(`/signin?next=${encodeURIComponent(next)}`); } return session; } diff --git a/app/app/routes/admin.tsx b/app/app/routes/admin.tsx index cfe73fe..c201b90 100644 --- a/app/app/routes/admin.tsx +++ b/app/app/routes/admin.tsx @@ -146,7 +146,7 @@ export default function AdminRoute() { return; } setAuthState("denied"); - window.location.replace("/admin/login?next=%2Fadmin"); + window.location.replace("/signin?next=%2Fadmin"); }) .catch(() => { if (alive) setAuthState("denied"); @@ -335,7 +335,7 @@ export default function AdminRoute() { {saving ? "กำลังบันทึก…" : "บันทึก"} -
+ -
+ -

+

ล็อกอินค้างไว้ 12 ชั่วโมง · ออกจากระบบได้จากหน้าหลังบ้าน

diff --git a/app/app/routes/signinsubmit.tsx b/app/app/routes/signinsubmit.tsx new file mode 100644 index 0000000..e32e82b --- /dev/null +++ b/app/app/routes/signinsubmit.tsx @@ -0,0 +1,26 @@ +import { redirect } from "react-router"; + +import { createSessionCookie, verifyCredentials } from "@/lib/auth.server"; + +/** รับฟอร์มล็อกอิน — /signinsubmit (action-only, ไม่ถูกส่งลง client bundle) */ +function safeNext(raw: string | null): string { + if (!raw) return "/admin"; + return raw.startsWith("/") && !raw.startsWith("//") ? raw : "/admin"; +} + +export async function action({ request }: { request: Request }) { + const form = await request.formData(); + const username = String(form.get("username") ?? "").trim(); + const password = String(form.get("password") ?? ""); + const next = safeNext(String(form.get("next") ?? "")); + + if (!verifyCredentials(username, password)) { + throw redirect(`/signin?error=1&next=${encodeURIComponent(next)}`); + } + + throw redirect(next, { headers: { "Set-Cookie": createSessionCookie() } }); +} + +export async function loader() { + throw redirect("/signin"); +} diff --git a/app/app/routes/admin.logout.tsx b/app/app/routes/signout.tsx similarity index 62% rename from app/app/routes/admin.logout.tsx rename to app/app/routes/signout.tsx index 015bb6f..e55abc3 100644 --- a/app/app/routes/admin.logout.tsx +++ b/app/app/routes/signout.tsx @@ -2,7 +2,7 @@ import { redirect } from "react-router"; import { clearSessionCookie } from "@/lib/auth.server"; -/** ออกจากระบบ — ล้าง cookie แล้วกลับหน้าแรก */ +/** ออกจากระบบ — /signout (action-only) */ export async function action() { throw redirect("/", { headers: { "Set-Cookie": clearSessionCookie() } }); } @@ -10,7 +10,3 @@ export async function action() { export async function loader() { throw redirect("/"); } - -export default function LogoutRoute() { - return null; -} diff --git a/app/public/data/theaters.json b/app/public/data/theaters.json index b0b448d..16dc329 100644 --- a/app/public/data/theaters.json +++ b/app/public/data/theaters.json @@ -1,5 +1,5 @@ { - "updated_at": "2026-10-27T15:19:41.647Z", + "updated_at": "2026-10-27T15:43:35.189Z", "theaters": [ { "slug": "house-cinema-samyan", @@ -95,7 +95,7 @@ } ], "hidden": false, - "image": null + "image": "/images/theaters/house-cinema-samyan-1793115815167.png" }, { "slug": "major-hollywood", diff --git a/app/public/images/theaters/house-cinema-samyan-1793115815167.png b/app/public/images/theaters/house-cinema-samyan-1793115815167.png new file mode 100644 index 0000000..4fdce5e Binary files /dev/null and b/app/public/images/theaters/house-cinema-samyan-1793115815167.png differ