auto_login answers {"auto_login": false} when auto-login is off
Hanzo CI/CD / cicd (push) Waiting to run
CI/CD / cicd (push) Waiting to run
security / semgrep (push) Successful in 4m52s

It answered 403, so every anonymous visit logged a failed request before
the login page appeared. The answer is now 200 with auto_login false,
like /v1/session answers unauthenticated visitors, and useGetAutoLogin
reads it and sets autoLogin to false. A request that fails still clears
autoLogin and retries as before.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
zooqueen
2026-09-15 12:45:59 -07:00
co-authored by Hanzo Dev
parent 6b38664be3
commit a594a05e86
3 changed files with 11 additions and 16 deletions
+1 -7
View File
@@ -133,13 +133,7 @@ async def auto_login(response: Response, db: DbSession):
return tokens
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail={
"message": "Auto login is disabled.",
"auto_login": False,
},
)
return {"auto_login": False}
@router.post("/refresh", include_in_schema=False)
+1 -2
View File
@@ -78,8 +78,7 @@ function ApiInterceptor() {
if (shouldRetryRefresh) {
if (
error?.config?.url?.includes("github") ||
error?.config?.url?.includes("public") ||
error?.config?.url?.includes("auto_login")
error?.config?.url?.includes("public")
) {
return Promise.reject(error);
}
@@ -19,7 +19,7 @@ export interface AutoLoginResponse {
health_check_max_retries: number;
}
export interface AutoLoginErrorResponse {
export interface AutoLoginDisabledResponse {
auto_login?: boolean;
}
@@ -44,7 +44,9 @@ export const useGetAutoLogin: useQueryFunctionType<undefined, undefined> = (
}
try {
const response = await api.get<Users>(`${getURL("AUTOLOGIN")}`);
const response = await api.get<Users & AutoLoginDisabledResponse>(
`${getURL("AUTOLOGIN")}`,
);
const user = response.data;
if (user && user["access_token"]) {
user["refresh_token"] = "auto";
@@ -52,15 +54,15 @@ export const useGetAutoLogin: useQueryFunctionType<undefined, undefined> = (
setUserData(user);
setAutoLogin(true);
resetTimer();
} else if (user?.auto_login === false) {
// The backend answers {"auto_login": false} when auto-login is off.
setAutoLogin(false);
}
} catch (e) {
const error = e as AxiosError<AutoLoginErrorResponse>;
const error = e as AxiosError;
if (error.name !== "CanceledError") {
setAutoLogin(false);
// Don't retry if backend explicitly says auto-login is disabled
const autoLoginDisabledByBackend =
error.response?.data?.auto_login === false;
if (!isLoginPage && !autoLoginDisabledByBackend) {
if (!isLoginPage) {
await handleAutoLoginError();
}
}