Handle OAuthErrorRespose from Account
All checks were successful
Build and Push Image / spfn-website (push) Successful in 2m49s

This commit is contained in:
BloxerHD 2026-07-02 20:33:34 +01:00
commit 7a95444cf9
Signed by: bloxerhd018
SSH key fingerprint: SHA256:ItSfcfhpXlfkMK3uQSDYW5X3XKm0hbHWQqWcCK57px8
2 changed files with 19 additions and 3 deletions

View file

@ -22,9 +22,10 @@ struct TokenRequest {
#[derive(Serialize, Deserialize)]
struct TokenResponse {
access_token: String,
token_type: String,
expires_in: i64,
access_token: Option<String>,
token_type: Option<String>,
expires_in: Option<i64>,
error: Option<String>,
}
pub fn router() -> Router {

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);