mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix chat and remove guid extension
This commit is contained in:
@@ -22,6 +22,8 @@ export class TokenInterceptor implements HttpInterceptor {
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private excludedDomains = ['Login', environment.apiChatUrl]; // Add the domains you want to exclude
|
||||||
|
|
||||||
constructor(private http: HttpClient, private router: Router,) { }
|
constructor(private http: HttpClient, private router: Router,) { }
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +31,11 @@ export class TokenInterceptor implements HttpInterceptor {
|
|||||||
request: HttpRequest<any>,
|
request: HttpRequest<any>,
|
||||||
next: HttpHandler
|
next: HttpHandler
|
||||||
): Observable<HttpEvent<any>> {
|
): Observable<HttpEvent<any>> {
|
||||||
|
|
||||||
|
if (this.shouldExcludeDomain(request)) {
|
||||||
|
return next.handle(request);
|
||||||
|
}
|
||||||
|
|
||||||
if (SessionStore.user.Authorization) {
|
if (SessionStore.user.Authorization) {
|
||||||
request = this.addToken(request, SessionStore.user.Authorization);
|
request = this.addToken(request, SessionStore.user.Authorization);
|
||||||
}
|
}
|
||||||
@@ -44,23 +51,24 @@ export class TokenInterceptor implements HttpInterceptor {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private shouldExcludeDomain(request: HttpRequest<any>): boolean {
|
||||||
|
const url = request.url.toLowerCase();
|
||||||
|
return this.excludedDomains.some((domain) => url.includes(domain.toLowerCase()));
|
||||||
|
}
|
||||||
|
|
||||||
private addToken(request: HttpRequest<any>, token: string) {
|
private addToken(request: HttpRequest<any>, token: string) {
|
||||||
|
|
||||||
if(request.url.includes("Login")) {
|
return request.clone({
|
||||||
return request.clone({});
|
setHeaders: {
|
||||||
} else {
|
//'Access-Control-Allow-Origin': '*',
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
return request.clone({
|
},
|
||||||
setHeaders: {
|
});
|
||||||
//'Access-Control-Allow-Origin': '*',
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handle401Error(request: HttpRequest<any>, next: HttpHandler) {
|
private handle401Error(request: HttpRequest<any>, next: HttpHandler) {
|
||||||
|
// if not getting the new token yet
|
||||||
if (!this.isRefreshing) {
|
if (!this.isRefreshing) {
|
||||||
this.isRefreshing = true;
|
this.isRefreshing = true;
|
||||||
this.refreshTokenSubject.next(null);
|
this.refreshTokenSubject.next(null);
|
||||||
@@ -73,6 +81,7 @@ export class TokenInterceptor implements HttpInterceptor {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// get new token
|
||||||
return this.refreshTokenSubject.pipe(
|
return this.refreshTokenSubject.pipe(
|
||||||
filter((token) => token != null),
|
filter((token) => token != null),
|
||||||
take(1),
|
take(1),
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ export class ChatService {
|
|||||||
|
|
||||||
async refreshtoken() {
|
async refreshtoken() {
|
||||||
|
|
||||||
/* if(this.headers && SessionStore.user.ChatData) {
|
if(this.headers && SessionStore.user.ChatData) {
|
||||||
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
this.headers = this.headers.set('Authorization', 'Bearer ' + SessionStore.user.Authorization);
|
||||||
let options = {
|
let options = {
|
||||||
headers: this.headers
|
headers: this.headers
|
||||||
@@ -423,7 +423,7 @@ export class ChatService {
|
|||||||
} else if (!this.headers) {
|
} else if (!this.headers) {
|
||||||
this.setheader()
|
this.setheader()
|
||||||
this.refreshtoken()
|
this.refreshtoken()
|
||||||
} */
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -451,7 +451,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
if(upload) {
|
if(upload) {
|
||||||
this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> {
|
this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> {
|
||||||
if(e.FileType == 'video') {
|
if(e.FileType == 'video') {
|
||||||
e.OriginalFileName = e.chucksManager.path
|
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
|
||||||
e.FileExtension = "mp4"
|
e.FileExtension = "mp4"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
if(upload) {
|
if(upload) {
|
||||||
this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> {
|
this.publication.Files = this.publication.Files.map((e:PublicationAttachmentEntity)=> {
|
||||||
if(e.FileType == 'video') {
|
if(e.FileType == 'video') {
|
||||||
e.OriginalFileName = e.chucksManager.path
|
e.OriginalFileName = e.chucksManager.path.replace(".mp4", "")
|
||||||
e.FileExtension = "mp4"
|
e.FileExtension = "mp4"
|
||||||
e.Base64 = ""
|
e.Base64 = ""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user