Skip to content

Commit

Permalink
fix(auth): don't send token when is null
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Feb 23, 2018
1 parent cce3c70 commit dd65dd1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/auth/shared/auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export class AuthInterceptor implements HttpInterceptor {
constructor(private tokenService: TokenService) {}

intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const authHeader = `Bearer ${this.tokenService.get()}`;
const token = this.tokenService.get();
if (!token) {
return next.handle(req);
}
const authHeader = `Bearer ${token}`;
const authReq = req.clone({headers: req.headers.set('Authorization', authHeader)});
return next.handle(authReq);
}
Expand Down

0 comments on commit dd65dd1

Please sign in to comment.