More Error Handling
All checks were successful
Build and Push Image / spfn-website (push) Successful in 2m52s
All checks were successful
Build and Push Image / spfn-website (push) Successful in 2m52s
This commit is contained in:
parent
7a95444cf9
commit
26f834810d
1 changed files with 10 additions and 0 deletions
|
|
@ -56,8 +56,18 @@ async function generateToken(username, password) {
|
||||||
throw new Error(`Token Generation Returned Error: ${data["error"]}`);
|
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"]);
|
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);
|
const expiry = Date.now() + (data["expires_in"] * 1000);
|
||||||
sessionStorage.setItem("authExpires", expiry)
|
sessionStorage.setItem("authExpires", expiry)
|
||||||
return data["access_token"];
|
return data["access_token"];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue