Refactor auth handling to improve token refresh logic
All checks were successful
SteamWarCI Build successful

This commit is contained in:
2025-03-01 11:30:30 +01:00
parent f03867b9a7
commit 4bbdaa06a9

View File

@ -133,7 +133,14 @@ export class AuthV2Repo {
try {
const response = await this.requestWithToken(this.refreshToken!, "/auth", {
method: "PUT",
}).then(value => value.json()).then(value => AuthTokenSchema.parse(value));
}).then(value => {
if (value.status === 401) {
throw new Error("Unauthorized");
}
return value;
}).then(value => value.json())
.then(value => AuthTokenSchema.parse(value));
this.setLoginState(response);
} catch (e) {
@ -163,7 +170,7 @@ export class AuthV2Repo {
},
})
.then(value => {
if (value.status === 401) {
if (value.status === 401 && url !== "/auth") {
this.refresh();
return this.requestWithToken(token, url, params, retryCount + 1);