Checkpoint: Authentication
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import {HttpInterceptorFn} from '@angular/common/http';
|
||||
|
||||
export const AuthInterceptorService: HttpInterceptorFn = (req, next) => {
|
||||
const token = localStorage.getItem('token');
|
||||
|
||||
if (token) {
|
||||
const clonedReq = req.clone({
|
||||
setHeaders: {
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return next(clonedReq);
|
||||
}
|
||||
|
||||
return next(req);
|
||||
};
|
||||
Reference in New Issue
Block a user