Skip to content

Commit e55ce4d

Browse files
authored
Merge pull request #3523 from rommapp/copilot/bugfix-bypass-autologin-feature
Fix bypass_autologin overwritten by 403 interceptor during app initialization
2 parents 05c1f88 + ccb8d40 commit e55ce4d

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

frontend/src/services/api/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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

frontend/src/views/Auth/Login.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { Emitter } from "mitt";
33
import { inject, onMounted, ref } from "vue";
44
import { useI18n } from "vue-i18n";
5-
import { useRouter } from "vue-router";
5+
import { useRoute, useRouter } from "vue-router";
66
import { refetchCSRFToken } from "@/services/api";
77
import identityApi from "@/services/api/identity";
88
import storeAuth from "@/stores/auth";
@@ -14,6 +14,7 @@ const heartbeatStore = storeHeartbeat();
1414
const authStore = storeAuth();
1515
const emitter = inject<Emitter<Events>>("emitter");
1616
const router = useRouter();
17+
const route = useRoute();
1718
const username = ref("");
1819
const password = ref("");
1920
const visiblePassword = ref(false);
@@ -97,8 +98,7 @@ async function loginOIDC() {
9798
}
9899
99100
onMounted(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
}

0 commit comments

Comments
 (0)