Gate GNSS (turning it on and its position) behind login
CI / check (push) Successful in 48s
CI / deploy (push) Successful in 23s

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:
randy committed 2026-09-08 14:06:29 +02:00
1 parent d9879bad60
commit 67585cd99a
6 files changed
+37 -12

No files matched your search

+14
View File
@@ -761,6 +761,20 @@ threading a separate flag through, since that's already there and
login state can't change without a full page reload anyway. Delete
exists on both file and folder rows — both are gated, easy to miss
one and only catch it by testing an actually-logged-out session.
`isLoggedIn()` itself lives in `public/js/auth.js` — shared with
`GnssControl` (below), the only other place gating on login.
`GET /api/gnss/position` requires login too, same reasoning — 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 (`isLoggedIn()`, same pattern as the tree
UI's write controls above) rather than shown and failing to ever get
a fix. `LocateControl` needs no gating of its own here: it only ever
reaches GNSS through `GnssControl#isEnabled()`, which can never turn
true for a logged-out visitor if the toggle that flips it is never on
the page to click — its browser-geolocation fallback stays open to
everyone, since that's a visitor's own device asking for their own
location, nothing to gate.
Login delegates to the Gitea instance at `git.priesol.net` via OAuth2
(`GET /login` redirects to Gitea's authorize endpoint, `GET