Handle OAuthErrorRespose from Account

This commit is contained in:
BloxerHD 2026-07-02 20:33:34 +01:00 committed by red binder
commit a5cc09537b
2 changed files with 19 additions and 3 deletions

View file

@ -41,6 +41,21 @@ async function generateToken(username, password) {
const data = await response.json();
if (data["error"]) {
let error = data["error"];
if (error == "invalid_client" || error == "unsupported_grant_type") {
loginError("Website is misconfigured, contact a SPFN developer to fix this", 502);
} else if (error == "invalid_request") {
loginError("Website sent invalid data to account, contact a SPFN developer to fix this", 502);
} else if (error == "invalid_grant") {
loginError("Invalid SFID or Password");
} else {
loginError(error);
}
throw new Error(`Token Generation Returned Error: ${data["error"]}`);
}
sessionStorage.setItem("authToken", data["access_token"]);
const expiry = Date.now() + (data["expires_in"] * 1000);