fix(auth): show actionable provider re-auth errors (#450)

This commit is contained in:
Iuliia Ivashko
2026-02-20 00:34:34 +02:00
committed by GitHub
parent 135b2c89be
commit 50a66bb6f1
4 changed files with 46 additions and 1 deletions
@@ -0,0 +1,34 @@
export const PROVIDER_AUTH_FAILURE_MESSAGE = "Authentication failed for this provider. Please re-authenticate and retry.";
export const isLikelyProviderAuthFailure = (value: unknown): boolean => {
if (typeof value !== "string") {
return false;
}
const detail = value.toLowerCase().trim();
if (!detail) {
return false;
}
if (
detail.includes("token refresh failed") ||
detail.includes("unauthorized") ||
detail.includes("invalid token") ||
detail.includes("expired token")
) {
return true;
}
const hasOauth = detail.includes("oauth");
const hasOauthFailure =
detail.includes("failed") || detail.includes("invalid") || detail.includes("expired");
if (hasOauth && hasOauthFailure) {
return true;
}
const has401 = /\b401\b/.test(detail);
const hasAuthContext =
detail.includes("auth") || detail.includes("token") || detail.includes("unauthorized");
return has401 && hasAuthContext;
};