diff --git a/src/components/repo/authv2.ts b/src/components/repo/authv2.ts index 0fc85b1..048da51 100644 --- a/src/components/repo/authv2.ts +++ b/src/components/repo/authv2.ts @@ -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);