TG-2 TG-9 - Push base Angular app

This commit is contained in:
2024-11-03 11:16:14 +01:00
parent cd590d21d9
commit 68d4b82756
36 changed files with 879 additions and 441 deletions

View File

@@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from "@angular/common/http";
import {Observable} from "rxjs";
@Injectable({
providedIn: 'root'
})
export class AuthInterceptorService implements HttpInterceptor {
intercept (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const tokenId = localStorage.getItem('tokenId');
if (!!tokenId) {
const cloned = req.clone({
headers: req.headers.set("Authorization",
"Bearer " + tokenId)
});
return next.handle(cloned);
}
return next.handle(req);
}
constructor() { }
}