diff --git a/src/app/interceptors/token.interceptors.ts b/src/app/interceptors/token.interceptors.ts index d087096b8..6d40566b8 100644 --- a/src/app/interceptors/token.interceptors.ts +++ b/src/app/interceptors/token.interceptors.ts @@ -22,6 +22,8 @@ export class TokenInterceptor implements HttpInterceptor { null ); + private excludedDomains = ['Login', environment.apiChatUrl]; // Add the domains you want to exclude + constructor(private http: HttpClient, private router: Router,) { } @@ -29,6 +31,11 @@ export class TokenInterceptor implements HttpInterceptor { request: HttpRequest, next: HttpHandler ): Observable> { + + if (this.shouldExcludeDomain(request)) { + return next.handle(request); + } + if (SessionStore.user.Authorization) { request = this.addToken(request, SessionStore.user.Authorization); } @@ -44,23 +51,24 @@ export class TokenInterceptor implements HttpInterceptor { ); } + private shouldExcludeDomain(request: HttpRequest): boolean { + const url = request.url.toLowerCase(); + return this.excludedDomains.some((domain) => url.includes(domain.toLowerCase())); + } + private addToken(request: HttpRequest, token: string) { - if(request.url.includes("Login")) { - return request.clone({}); - } else { - - return request.clone({ - setHeaders: { - //'Access-Control-Allow-Origin': '*', - Authorization: `Bearer ${token}`, - }, - }); - } + return request.clone({ + setHeaders: { + //'Access-Control-Allow-Origin': '*', + Authorization: `Bearer ${token}`, + }, + }); } private handle401Error(request: HttpRequest, next: HttpHandler) { + // if not getting the new token yet if (!this.isRefreshing) { this.isRefreshing = true; this.refreshTokenSubject.next(null); @@ -73,6 +81,7 @@ export class TokenInterceptor implements HttpInterceptor { }) ); } else { + // get new token return this.refreshTokenSubject.pipe( filter((token) => token != null), take(1), diff --git a/src/app/services/chat.service.ts b/src/app/services/chat.service.ts index c650cdf12..236cd2fd0 100644 --- a/src/app/services/chat.service.ts +++ b/src/app/services/chat.service.ts @@ -370,7 +370,7 @@ export class ChatService { async refreshtoken() { - /* if(this.headers && SessionStore.user.ChatData) { + if(this.headers && SessionStore.user.ChatData) { this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization); let options = { headers: this.headers @@ -423,7 +423,7 @@ export class ChatService { } else if (!this.headers) { this.setheader() this.refreshtoken() - } */ + } } diff --git a/src/app/shared/publication/new-publication/new-publication.page.ts b/src/app/shared/publication/new-publication/new-publication.page.ts index 54cbb977e..3a7a15016 100644 --- a/src/app/shared/publication/new-publication/new-publication.page.ts +++ b/src/app/shared/publication/new-publication/new-publication.page.ts @@ -451,7 +451,7 @@ export class NewPublicationPage implements OnInit { if(upload) { this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> { if(e.FileType == 'video') { - e.OriginalFileName = e.chucksManager.path + e.OriginalFileName = e.chucksManager.path.replace(".mp4", "") e.FileExtension = "mp4" } @@ -513,7 +513,7 @@ export class NewPublicationPage implements OnInit { if(upload) { this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> { if(e.FileType == 'video') { - e.OriginalFileName = e.chucksManager.path + e.OriginalFileName = e.chucksManager.path.replace(".mp4", "") e.FileExtension = "mp4" e.Base64 = "" }