ui: handle rate limit for client

This commit is contained in:
pommee
2025-06-17 18:54:59 +02:00
parent e667c3901a
commit bb08060442
2 changed files with 10 additions and 2 deletions
+9 -1
View File
@@ -75,12 +75,13 @@ export function Login({
}
try {
const [statusCode] = await PostRequest(
const [statusCode, response] = await PostRequest(
"login",
{
username,
password
},
true,
true
);
@@ -90,6 +91,13 @@ export function Login({
}
navigate("/");
} else if (statusCode === 429) {
toast.warning("Rate limit exceeded", {
description: `Retry again in ${response.retryAfterSeconds} seconds`
});
return;
} else {
toast.warning("Login failed", { description: response.error });
}
} catch (error) {
console.error("Login error:", error);
+1 -1
View File
@@ -62,7 +62,7 @@ export async function PostRequest(
if (ignoreError !== true) {
showToast(data.error || "Unknown error occurred");
}
return [res.status, null];
return [res.status, data];
}
const data = await tryParseJson();