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
@@ -0,0 +1,9 @@
|
||||
// No server-rendered flag for this exists, and adding one would be more
|
||||
// plumbing than reusing what's already on the page: the topbar's own
|
||||
// logged_in check (views/index.erb) already renders a "Log out" link only
|
||||
// when logged in. Login state never changes without a full page reload
|
||||
// (there's no client-side login/logout), so this only needs checking once
|
||||
// per use, not reactively/on an event.
|
||||
export function isLoggedIn() {
|
||||
return !!document.querySelector('a[href="/logout"]');
|
||||
}
|
||||
Reference in new issue
Block a user