source: bus-n-go-pavel-216049/bus-n-go-frontend/src/app/interceptors/auth.interceptor.ts@ bfb90dd

Last change on this file since bfb90dd was baf4cc4, checked in by ppaunovski <paunovskipavel@…>, 4 weeks ago

split group project and individual project into two separate folders

  • Property mode set to 100644
File size: 386 bytes
Line 
1import {HttpInterceptorFn} from '@angular/common/http';
2
3export const authInterceptor: HttpInterceptorFn = (req, next) => {
4 const jwt = sessionStorage.getItem('jwt');
5 if (jwt && jwt.length > 0) {
6 const newReq = req.clone({
7 setHeaders: {
8 Authorization: `Bearer ${sessionStorage.getItem('jwt')}`,
9 },
10 });
11 return next(newReq);
12 }
13 return next(req);
14};
Note: See TracBrowser for help on using the repository browser.