Skip to content

Commit

Permalink
✨ feat: added orgId to request header (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmos-explorer committed Mar 21, 2023
1 parent 1dae68a commit b0eb8d7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {catchError, map} from 'rxjs/operators';
import {Router} from "@angular/router";
import {NzMessageService} from "ng-zorro-antd/message";
import {Injectable} from "@angular/core";
import {IDENTITY_TOKEN} from "../../shared/utils/localstorage-keys";
import { CURRENT_ORGANIZATION, IDENTITY_TOKEN } from "../../shared/utils/localstorage-keys";
import {IResponse} from "@shared/types";

@Injectable()
Expand All @@ -23,8 +23,13 @@ export class RequestResponseInterceptor implements HttpInterceptor {
) { }

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<unknown>> {
const token = localStorage.getItem(IDENTITY_TOKEN);
const currentOrgId = JSON.parse(localStorage.getItem(CURRENT_ORGANIZATION()))?.id ?? '';

const authedReq = request.clone({
headers: request.headers.set('Authorization', 'Bearer ' + localStorage.getItem(IDENTITY_TOKEN))
headers: request.headers
.set('Authorization', `Bearer ${token}`)
.set('Organization', currentOrgId)
});

return next.handle(authedReq)
Expand Down

0 comments on commit b0eb8d7

Please sign in to comment.