Browse Source

Add autoAuthorizedUris

Matt Raible 7 years ago
parent
commit
7624809f08
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      TUTORIAL.md

+ 14
- 2
TUTORIAL.md View File

361
 
361
 
362
 ```typescript
362
 ```typescript
363
 import { Injectable } from '@angular/core';
363
 import { Injectable } from '@angular/core';
364
-import { Http, Response } from '@angular/http';
364
+import { Http, Response, RequestOptions } from '@angular/http';
365
 import 'rxjs/add/operator/map';
365
 import 'rxjs/add/operator/map';
366
 import { Observable } from 'rxjs';
366
 import { Observable } from 'rxjs';
367
 import { StormpathConfiguration } from 'angular-stormpath';
367
 import { StormpathConfiguration } from 'angular-stormpath';
377
   }
377
   }
378
 
378
 
379
   getGoodBeers(): Observable<any> {
379
   getGoodBeers(): Observable<any> {
380
-    return this.http.get(this.API + '/good-beers')
380
+    let options = new RequestOptions({ withCredentials: true });
381
+    return this.http.get(this.API + '/good-beers', options)
381
       .map((response: Response) => response.json());
382
       .map((response: Response) => response.json());
382
   }
383
   }
383
 }
384
 }
384
 ```
385
 ```
385
 
386
 
387
+**TIP:** If you don’t want to pass in `withCredentials: true`, you can add the API URI as an `autoAuthorizeUri` in `StormpathConfiguration`.
388
+
389
+```typescript
390
+export function stormpathConfig(): StormpathConfiguration {
391
+  let spConfig: StormpathConfiguration = new StormpathConfiguration();
392
+  spConfig.endpointPrefix = 'http://localhost:8080';
393
+  spConfig.autoAuthorizedUris.push(new RegExp('http://localhost:8080/good-beers'));
394
+  return spConfig;
395
+}
396
+```
397
+
386
 Modify `beer.html` to show the list of beers.
398
 Modify `beer.html` to show the list of beers.
387
 
399
 
388
 ```html
400
 ```html