From b32427617321c042e239f930db7fdcb5c2438543 Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 2 Sep 2025 19:08:16 -0600 Subject: [PATCH] Cleaned up login/logout flows. --- frontend/src/App.vue | 8 ++++++-- frontend/src/components/LoginView.vue | 6 +++--- frontend/src/components/PermissionDeniedView.vue | 1 - frontend/src/components/ProfileView.vue | 1 - frontend/src/stores/auth.js | 9 +++++---- passkey/fastapi/admin.py | 12 +++++++++--- passkey/fastapi/authz.py | 14 ++++++++++++++ passkey/fastapi/mainapp.py | 13 +++++++++---- 8 files changed, 46 insertions(+), 18 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index d99223f..e7cdcf8 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -22,8 +22,12 @@ import PermissionDeniedView from '@/components/PermissionDeniedView.vue' const store = useAuthStore() onMounted(async () => { - // Detect restricted mode: any path not starting with /auth/ - if (!location.pathname.startsWith('/auth/')) { + // Detect restricted mode: + // We only allow full functionality on the exact /auth/ (or /auth) path. + // Any other path (including /, /foo, /auth/admin, etc.) is treated as restricted + // so the app will only show login or permission denied views. + const path = location.pathname + if (!(path === '/auth/' || path === '/auth')) { store.setRestrictedMode(true) } // Load branding / settings first (non-blocking for auth flow) diff --git a/frontend/src/components/LoginView.vue b/frontend/src/components/LoginView.vue index 1bbf848..5579b8c 100644 --- a/frontend/src/components/LoginView.vue +++ b/frontend/src/components/LoginView.vue @@ -27,9 +27,9 @@ const handleLogin = async () => { await authStore.authenticate() authStore.showMessage('Authentication successful!', 'success', 2000) if (authStore.restrictedMode) { - // In restricted mode after successful auth show permission denied (no profile outside /auth/) - authStore.currentView = 'permission-denied' - } else if (location.pathname.startsWith('/auth/')) { + // Restricted mode: reload so the app re-mounts and selectView() applies (will become permission denied) + location.reload() + } else if (location.pathname === '/auth/') { authStore.currentView = 'profile' } else { location.reload() diff --git a/frontend/src/components/PermissionDeniedView.vue b/frontend/src/components/PermissionDeniedView.vue index a68bbce..ba5764c 100644 --- a/frontend/src/components/PermissionDeniedView.vue +++ b/frontend/src/components/PermissionDeniedView.vue @@ -32,7 +32,6 @@ function back() { } async function logout() { await authStore.logout() - authStore.currentView = 'login' }