wip
This commit is contained in:
parent
144f033beb
commit
e848b548b5
7 changed files with 65 additions and 25 deletions
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
Reference in a new issue