mirror of
https://github.com/pommee/goaway.git
synced 2026-05-18 07:18:45 -05:00
ui: handle rate limit for client
This commit is contained in:
@@ -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
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user