diff --git a/src/components/repo/authv2.ts b/src/components/repo/authv2.ts index 048da51..e3aa1ec 100644 --- a/src/components/repo/authv2.ts +++ b/src/components/repo/authv2.ts @@ -130,24 +130,20 @@ export class AuthV2Repo { return; } - try { - const response = await this.requestWithToken(this.refreshToken!, "/auth", { - method: "PUT", - }).then(value => { - if (value.status === 401) { - throw new Error("Unauthorized"); - } + const response = await this.requestWithToken(this.refreshToken!, "/auth", { + method: "PUT", + }).then(value => { + if (value.status === 401) { + this.resetRefreshToken(); + this.resetAccessToken(); - return value; - }).then(value => value.json()) - .then(value => AuthTokenSchema.parse(value)); + return undefined; + } - this.setLoginState(response); - } catch (e) { - this.resetRefreshToken(); - this.resetAccessToken(); - return; - } + return value.json(); + }).then(value => AuthTokenSchema.parse(value)); + + this.setLoginState(response); } async request(url: string, params: RequestInit = {}) {