Refactor auth handling to improve token refresh logic
All checks were successful
SteamWarCI Build successful
All checks were successful
SteamWarCI Build successful
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user