File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -74,9 +74,17 @@ api.interceptors.response.use(
7474 const params = new URLSearchParams ( search ) ;
7575 const fullPath = pathname + search ;
7676
77- // Don't redirect to login if already on an auth-exempt route
77+ // Don't redirect to login if already on an auth-exempt route.
78+ // Also resolve the route from the browser URL to handle the case where
79+ // the router hasn't been started yet (e.g., during app initialization),
80+ // which would otherwise cause router.currentRoute.value.name to be undefined.
7881 const currentRoute = router . currentRoute . value . name ?. toString ( ) ?? "" ;
79- if ( isAuthExemptRoute ( currentRoute ) ) {
82+ const resolvedRoute = router . resolve ( window . location . pathname ) ;
83+ const resolvedRouteName = resolvedRoute . name ?. toString ( ) ?? "" ;
84+ if (
85+ isAuthExemptRoute ( currentRoute ) ||
86+ isAuthExemptRoute ( resolvedRouteName )
87+ ) {
8088 return Promise . reject ( error ) ;
8189 }
8290
Original file line number Diff line number Diff line change 22import type { Emitter } from " mitt" ;
33import { inject , onMounted , ref } from " vue" ;
44import { useI18n } from " vue-i18n" ;
5- import { useRouter } from " vue-router" ;
5+ import { useRoute , useRouter } from " vue-router" ;
66import { refetchCSRFToken } from " @/services/api" ;
77import identityApi from " @/services/api/identity" ;
88import storeAuth from " @/stores/auth" ;
@@ -14,6 +14,7 @@ const heartbeatStore = storeHeartbeat();
1414const authStore = storeAuth ();
1515const emitter = inject <Emitter <Events >>(" emitter" );
1616const router = useRouter ();
17+ const route = useRoute ();
1718const username = ref (" " );
1819const password = ref (" " );
1920const visiblePassword = ref (false );
@@ -97,8 +98,7 @@ async function loginOIDC() {
9798}
9899
99100onMounted (async () => {
100- const params = new URLSearchParams (window .location .search );
101- const bypassAutologin = params .get (" bypass_autologin" ) === " true" ;
101+ const bypassAutologin = route .query .bypass_autologin === " true" ;
102102 if (oidcEnabled && oidcAutologin && ! bypassAutologin ) {
103103 loginOIDC ();
104104 }
You can’t perform that action at this time.
0 commit comments