mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-06-10 17:04:50 +02:00
navi: read auth login/logout URLs from /api/config (extraction #2 PR-C)
Panel.jsx now reads the login/logout URLs from the deployment config (cfg.auth.login_url / cfg.auth.logout_url) instead of hardcoding them, with the current home-profile literals kept as fallback. This completes the extraction #2 trio: - PR-A (recon #6): adds the `auth` block to the deployment profile YAMLs - PR-B (navi-backend #1): navi-config service serving /api/config on :8422 - PR-C (this): frontend consumes auth.* from /api/config Behavior is unchanged in every case: the fallback literals are used if the backend doesn't yet serve `auth` (older recon) or when FALLBACK_CONFIG is in effect (offline / config API unreachable). useConfig() returns the cached deployment config (null until loaded); the optional-chaining + ?? fallback keeps clicks working before config loads. Also adds the same `auth` block to src/config.js FALLBACK_CONFIG so offline mode has working URLs. No test added: navi has no test infrastructure today; flagged with a TODO(navi) at the change site for when test infra lands. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fcc9101239
commit
38d11bea99
2 changed files with 12 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ import { LogIn, LogOut, Footprints, Bike, Car, Shield, AlertTriangle, Zap, X, Ma
|
|||
import ThemePicker from './ThemePicker'
|
||||
import { useStore, usePanelState } from '../store'
|
||||
import { hasFeature } from '../config'
|
||||
import { useConfig } from '../hooks/useConfig'
|
||||
import SearchBar from './SearchBar'
|
||||
import ManeuverList from './ManeuverList'
|
||||
import ContactList from './ContactList'
|
||||
|
|
@ -54,6 +55,7 @@ export default function Panel({ onClearRoute }) {
|
|||
const dragStartState = useRef('half')
|
||||
|
||||
const showContacts = hasFeature('has_contacts') && auth.authenticated
|
||||
const cfg = useConfig()
|
||||
|
||||
useEffect(() => {
|
||||
const check = () => setIsMobile(window.innerWidth < 768)
|
||||
|
|
@ -62,8 +64,12 @@ export default function Panel({ onClearRoute }) {
|
|||
return () => window.removeEventListener('resize', check)
|
||||
}, [])
|
||||
|
||||
const handleLogin = () => { window.location.href = '/outpost.goauthentik.io/start?rd=%2F' }
|
||||
const handleLogout = () => { window.location.href = 'https://auth.echo6.co/if/flow/default-invalidation-flow/?next=https://navi.echo6.co/' }
|
||||
// Auth URLs come from /api/config (config.auth.*); the literals are the
|
||||
// current home-profile values, kept as fallback for an older backend that
|
||||
// doesn't yet serve `auth`, or when FALLBACK_CONFIG is in use (offline).
|
||||
// TODO(navi): add tests when test infra lands — see extraction #2 PR-C
|
||||
const handleLogin = () => { window.location.href = cfg?.auth?.login_url ?? '/outpost.goauthentik.io/start?rd=%2F' }
|
||||
const handleLogout = () => { window.location.href = cfg?.auth?.logout_url ?? 'https://auth.echo6.co/if/flow/default-invalidation-flow/?next=https://navi.echo6.co/' }
|
||||
|
||||
const handleTouchStart = useCallback((e) => {
|
||||
dragStartY.current = e.touches[0].clientY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue