Refine token validation and update user stats endpoint.
All checks were successful
SteamWarCI Build successful

Extend access token validation to include a 10-second buffer to prevent potential expiry issues. Modify the user stats API call to use the base `/stats/user` endpoint for improved consistency.
This commit is contained in:
2025-02-18 00:09:06 +01:00
parent 87265e5ccc
commit 2c63a33bda
2 changed files with 2 additions and 2 deletions

View File

@ -155,7 +155,7 @@ export class AuthV2Repo {
} }
async request(url: string, params: RequestInit = {}) { async request(url: string, params: RequestInit = {}) {
if (this.accessToken !== undefined && this.accessTokenExpires !== undefined && this.accessTokenExpires.isBefore(dayjs())) { if (this.accessToken !== undefined && this.accessTokenExpires !== undefined && this.accessTokenExpires.isBefore(dayjs().add(10, "seconds"))) {
await this.refresh(); await this.refresh();
} }

View File

@ -36,7 +36,7 @@ export class StatsRepo {
} }
public async getUserStats(id: string): Promise<UserStats> { public async getUserStats(id: string): Promise<UserStats> {
return await fetchWithToken(this.token, `/stats/user/${id}`).then(value => value.json()).then(UserStatsSchema.parse); return await fetchWithToken(this.token, `/stats/user`).then(value => value.json()).then(UserStatsSchema.parse);
} }
} }