Gate GNSS (turning it on and its position) behind login
GET /api/gnss/position now requires login (app.rb) -- it reveals where the receiver physically is, not something to leave open to anyone with the URL. GnssControl's sidebar icon is hidden entirely when logged out (same pattern as the tree UI's write controls) rather than shown and failing to ever get a fix. LocateControl needs no changes: it only ever reaches GNSS through GnssControl#isEnabled(), which can't turn true for a logged-out visitor if the toggle is never on the page to click. Its browser-geolocation fallback stays open to everyone -- a visitor's own device asking for their own location isn't something to gate. Extracted isLoggedIn() out of gpx.js into a shared public/js/auth.js (gnss.js needed the same check) rather than duplicating it. Verified: /api/gnss/position returns 401 logged out; the sidebar icon is actually hidden (computed display: none, not just present-but- unstyled -- checked properly this time after almost repeating the same present-vs-visible test mistake the .gpx-panel__action bug already taught).
This commit is contained in:
1 parent
d9879bad60
commit
67585cd99a
6 files changed
+37
-12
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { Marker } from "/vendor/maplibre-gl/maplibre-gl.mjs";
|
||||
import { GNSS_ICON } from "/js/icons.js";
|
||||
import { isLoggedIn } from "/js/auth.js";
|
||||
|
||||
const POSITION_URL = "/api/gnss/position";
|
||||
const POLL_INTERVAL_MS = 1500;
|
||||
@@ -41,6 +42,12 @@ export class GnssControl {
|
||||
this._status = this._container.querySelector(".gnss-control__status");
|
||||
this._icon.addEventListener("click", () => this._setEnabled(!this._enabled));
|
||||
|
||||
// GET /api/gnss/position itself requires login too (app.rb) — hidden
|
||||
// here rather than shown and failing on click, same reasoning as
|
||||
// gpx.js's write-action controls: it reveals where the receiver
|
||||
// physically is, not something to leave open to anyone with the URL.
|
||||
if (!isLoggedIn()) this._container.hidden = true;
|
||||
|
||||
sidebar.appendChild(this._container);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user