This commit is contained in:
csimonis 2025-03-12 14:45:40 +01:00 committed by Constantin Simonis
commit e848b548b5
No known key found for this signature in database
GPG key ID: 3878FF77C24AF4D2
7 changed files with 65 additions and 25 deletions

View file

@ -1,9 +1,9 @@
import { HttpInterceptorFn } from '@angular/common/http';
import { inject } from '@angular/core';
import { AuthService } from '../../service/auth.service';
export const httpInterceptor: HttpInterceptorFn = (req, next) => {
return next(req.clone({
setHeaders: {'Authorization': 'Bearer '+inject(AuthService).getAccessToken()},
}));
if (localStorage.getItem('jwt')) {
return next(req.clone({ setHeaders: { 'Authorization': 'Bearer ' + localStorage.getItem('jwt') } }));
} else {
return next(req);
}
};