- Pin Dockerfile to Go 1.23 to match go.mod - Record README front-door audit findings
26 lines
1.3 KiB
JavaScript
26 lines
1.3 KiB
JavaScript
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
|
|
|
|
// grant-valid-until-tz.js
|
|
//
|
|
// The operator grant forms use <input type="datetime-local" name="valid_until">,
|
|
// which submits a naive wall-clock string with no timezone. Without help, the
|
|
// server can only assume its own local zone — wrong when the operator's browser
|
|
// is in a different timezone than the deployment. This attaches the browser's
|
|
// UTC offset (in minutes, for the *picked* date so DST is handled) as
|
|
// valid_until_offset on every HTMX request that carries a valid_until, letting
|
|
// the server resolve the exact instant. Pure progressive enhancement: if this
|
|
// script doesn't run, the server falls back to its local zone.
|
|
(function () {
|
|
document.body.addEventListener("htmx:config:request", function (evt) {
|
|
var ctx = evt.detail && evt.detail.ctx;
|
|
var body = ctx && ctx.request && ctx.request.body;
|
|
if (!body || typeof body.get !== "function") return; // FormData on mutations only
|
|
var v = body.get("valid_until");
|
|
if (!v) return;
|
|
var picked = new Date(v); // datetime-local → local time for that date
|
|
if (isNaN(picked.getTime())) return;
|
|
body.set("valid_until_offset", String(picked.getTimezoneOffset()));
|
|
});
|
|
})();
|