forked from spacebar/spfn-website
Handle OAuthErrorRespose from Account
This commit is contained in:
parent
517a9fad39
commit
a5cc09537b
2 changed files with 19 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue