rsanchez
2017-03-22 60c65f2110f65221bc3a71b2887667e78c53c53e
securis/src/main/webapp/src/app/common/default.requests.options.ts
....@@ -23,11 +23,6 @@
2323
2424 // Set the default 'Content-Type' header
2525 this.headers.set('Content-Type', 'application/json');
26
- let token = this.store.get<string>('token');
27
- if (token) {
28
- this.headers.set('X-SECURIS-TOKEN', token);
29
-
30
- }
3126
3227 }
3328 }
....@@ -35,11 +30,15 @@
3530 @Injectable()
3631 export class ApiXHRBackend extends XHRBackend {
3732
38
- constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy) {
33
+ constructor(_browserXHR: BrowserXhr, _baseResponseOptions: ResponseOptions, _xsrfStrategy: XSRFStrategy, private store: LocalStorageService) {
3934 super(_browserXHR, _baseResponseOptions, _xsrfStrategy);
4035 }
4136
4237 createConnection(request: Request): XHRConnection {
38
+ let token = this.store.get<string>('token');
39
+ if (token) {
40
+ request.headers.set('X-SECURIS-TOKEN', token);
41
+ }
4342 if (!request.url.endsWith('.js') && !request.url.endsWith('.json') && !request.url.endsWith('.html') && !request.url.endsWith('.svg')){
4443 request.url = 'http://localhost:8080/securis/' + request.url; // prefix base url
4544 }