Skip to content

Commit 9f2003a

Browse files
committed
Improve auth check condition
1 parent e2d5ebc commit 9f2003a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/api/DigmaApiClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ export class DigmaApiClient {
3939
}
4040

4141
private isAuthenticationRequired(url: string): boolean {
42-
return this.authEndpoints.some((endpoint) => url.endsWith(endpoint));
42+
return this.authEndpoints.some((endpoint) => !url.endsWith(endpoint));
4343
}
4444

4545
private setupInterceptors(): void {
4646
// Request interceptor to check token expiry
4747
this.instance.interceptors.request.use(
4848
async (config) => {
4949
// Skip token check for authentication endpoints
50-
if (config.url && this.isAuthenticationRequired(config.url)) {
50+
if (config.url && !this.isAuthenticationRequired(config.url)) {
5151
return config;
5252
}
5353

@@ -76,7 +76,7 @@ export class DigmaApiClient {
7676
// Skip retry for authentication endpoints to avoid loops
7777
if (
7878
originalRequest?.url &&
79-
this.isAuthenticationRequired(originalRequest.url)
79+
!this.isAuthenticationRequired(originalRequest.url)
8080
) {
8181
return Promise.reject(error);
8282
}
@@ -114,7 +114,7 @@ export class DigmaApiClient {
114114

115115
private isTokenExpired(session: UserSession): boolean {
116116
const expiration = new Date(session.expiration).valueOf();
117-
return expiration < Date.now();
117+
return expiration <= Date.now();
118118
}
119119

120120
private async handleTokenRefresh(): Promise<void> {

0 commit comments

Comments
 (0)