new Landing page, stripped app

This commit is contained in:
2025-04-05 12:25:50 +02:00
parent b39370a6b5
commit 83808263af
165 changed files with 9484 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, from } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { environment } from '../../environments/environment';
import { AuthService } from '../services/auth.service';
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor(private authService: AuthService) {}
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
// Prüfe, ob die Anfrage an die apiBaseUrl gerichtet ist
const isApiRequest = req.url.startsWith(environment.apiBaseUrl);
if (!isApiRequest) {
// Wenn es keine API-Anfrage ist, leite die Anfrage unverändert weiter
return next.handle(req);
}
// Wenn es eine API-Anfrage ist, füge den Token hinzu (falls vorhanden)
return from(this.authService.getToken()).pipe(
switchMap(token => {
if (token) {
const clonedReq = req.clone({
setHeaders: { Authorization: `Bearer ${token}` },
});
return next.handle(clonedReq);
}
return next.handle(req);
}),
);
}
}