18 lines
808 B
TypeScript
18 lines
808 B
TypeScript
export async function loginErrorMessage(response: Response): Promise<string> {
|
|
if (response.status === 429) return "Too many attempts. Please wait a moment and try again.";
|
|
if (response.status >= 500) return "Sign-in is temporarily unavailable. Please try again shortly.";
|
|
if (response.status === 403) {
|
|
const payload: unknown = await response.json().catch(() => null);
|
|
if (
|
|
payload !== null &&
|
|
typeof payload === "object" &&
|
|
"detail" in payload &&
|
|
payload.detail === "Cross-origin state change rejected"
|
|
) {
|
|
return "Sign-in was blocked by the site's security configuration. Please contact an administrator.";
|
|
}
|
|
return "This account cannot sign in. Please contact an administrator.";
|
|
}
|
|
return "Check your username and password, then try again.";
|
|
}
|