More Error Handling
All checks were successful
Build and Push Image / spfn-website (push) Successful in 2m52s

This commit is contained in:
BloxerHD 2026-07-02 21:24:17 +01:00
commit 26f834810d
Signed by: bloxerhd018
SSH key fingerprint: SHA256:ItSfcfhpXlfkMK3uQSDYW5X3XKm0hbHWQqWcCK57px8

View file

@ -56,8 +56,18 @@ async function generateToken(username, password) {
throw new Error(`Token Generation Returned Error: ${data["error"]}`);
}
if (!data["access_token"]) {
loginError("Malformed Response from API, contact a SPFN developer to fix this", 502);
throw new Error(`No Token in Response from API but No Error Field Either: ${data}`)
}
sessionStorage.setItem("authToken", data["access_token"]);
if (!data["expires_in"]) {
loginError("Malformed Response from API, contact a SPFN developer to fix this", 502);
throw new Error(`No Expiry in Response from API but No Error Field Either: ${data}`)
}
const expiry = Date.now() + (data["expires_in"] * 1000);
sessionStorage.setItem("authExpires", expiry)
return data["access_token"];