refactor: remove log

This commit is contained in:
Polianin Nikita 2024-08-24 04:28:23 +03:00
parent 1f03c2a9c3
commit b215d8909c
2 changed files with 1 additions and 7 deletions

View File

@ -57,7 +57,6 @@ export class AuthService {
public refreshToken(): Observable<Date> { public refreshToken(): Observable<Date> {
const token = localStorage.getItem(ApiService.tokenKey); const token = localStorage.getItem(ApiService.tokenKey);
console.log(token);
if (!token) if (!token)
return throwError(() => new Error("Token is not found")); return throwError(() => new Error("Token is not found"));

View File

@ -1,4 +1,4 @@
import {BehaviorSubject, catchError, of, Subject, Subscription} from "rxjs"; import {BehaviorSubject, catchError, of, Subject} from "rxjs";
import {Injectable} from "@angular/core"; import {Injectable} from "@angular/core";
import {AuthService} from "@service/auth.service"; import {AuthService} from "@service/auth.service";
import {environment} from "@environment"; import {environment} from "@environment";
@ -27,28 +27,23 @@ export class TokenRefreshService {
private refreshToken(): void { private refreshToken(): void {
if (this.tokenRefreshing$.value) { if (this.tokenRefreshing$.value) {
console.warn('Refreshing token was started...');
return; return;
} }
console.log('Start Refreshing token...');
this.tokenRefreshing$.next(true); this.tokenRefreshing$.next(true);
this.authService.refreshToken() this.authService.refreshToken()
.pipe( .pipe(
catchError(error => { catchError(error => {
console.warn('Error refreshing token', error);
localStorage.removeItem(ApiService.tokenKey); localStorage.removeItem(ApiService.tokenKey);
this.refreshTokenExpireMs = -1; this.refreshTokenExpireMs = -1;
return of(undefined); return of(undefined);
})) }))
.subscribe(data => { .subscribe(data => {
if (data) { if (data) {
console.log('Token refreshed');
this.setRefreshTokenExpireMs(data); this.setRefreshTokenExpireMs(data);
} }
this.tokenRefreshing$.next(false); this.tokenRefreshing$.next(false);
console.log('Token refresh process completed');
}); });
} }