hhhhhnnn mimimimimimimimi
This commit is contained in:
parent
0114214995
commit
441f00507d
4 changed files with 68 additions and 9 deletions
|
|
@ -114,7 +114,7 @@ async function authenticate() {
|
|||
const refresh_token = localStorage.getItem("refresh_token");
|
||||
|
||||
if (refresh_token !== null) {
|
||||
return true;
|
||||
return await refreshToken(refresh_token);
|
||||
}
|
||||
|
||||
localStorage.clear();
|
||||
|
|
@ -130,13 +130,13 @@ async function authenticate() {
|
|||
* body, rather than just the body
|
||||
*/
|
||||
async function authedAPIRequest(endpoint, options) {
|
||||
if (!authenticate()) {
|
||||
if (!(await authenticate())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!options.method) {
|
||||
console.error("Invalid parameter: options (missing method)");
|
||||
return null
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!options.headers) {
|
||||
|
|
@ -159,12 +159,12 @@ async function authedAPIRequest(endpoint, options) {
|
|||
const response_err = await response.text();
|
||||
|
||||
if (response_err.includes("Token expired")) {
|
||||
refreshToken(null);
|
||||
await refreshToken(null);
|
||||
return null;
|
||||
}
|
||||
|
||||
localStorage.clear();
|
||||
alert("Redirecting to logging page")
|
||||
alert("Redirecting to logging page");
|
||||
redirect.redirectToLoginPage();
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue