diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-07-20 16:24:18 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-07-20 16:25:06 +0200 |
commit | bd5c83a8cb46eb6da2b25df3b1f6a2a5795d1869 (patch) | |
tree | 66df283a1554f27b92e392fca36b8e272d7535bc /client/src/main.ts | |
parent | 2f372a865487427ff97ad17edd0e6adfbb478c80 (diff) | |
download | PeerTube-bd5c83a8cb46eb6da2b25df3b1f6a2a5795d1869.tar.gz PeerTube-bd5c83a8cb46eb6da2b25df3b1f6a2a5795d1869.tar.zst PeerTube-bd5c83a8cb46eb6da2b25df3b1f6a2a5795d1869.zip |
Client: Add authHttp service that authentificates the http request and
optionally refresh the access token if needed
Diffstat (limited to 'client/src/main.ts')
-rw-r--r-- | client/src/main.ts | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/client/src/main.ts b/client/src/main.ts index f9c1d50b8..a78d275ad 100644 --- a/client/src/main.ts +++ b/client/src/main.ts | |||
@@ -1,12 +1,28 @@ | |||
1 | import { enableProdMode } from '@angular/core'; | 1 | import { enableProdMode, provide } from '@angular/core'; |
2 | import { | ||
3 | HTTP_PROVIDERS, | ||
4 | RequestOptions, | ||
5 | XHRBackend | ||
6 | } from '@angular/http'; | ||
2 | import { bootstrap } from '@angular/platform-browser-dynamic'; | 7 | import { bootstrap } from '@angular/platform-browser-dynamic'; |
3 | import { provideRouter } from '@angular/router'; | 8 | import { provideRouter } from '@angular/router'; |
4 | 9 | ||
5 | import { AppComponent } from './app/app.component'; | 10 | import { AppComponent } from './app/app.component'; |
6 | import { routes } from './app/app.routes'; | 11 | import { routes } from './app/app.routes'; |
12 | import { AuthHttp, AuthService } from './app/shared'; | ||
7 | 13 | ||
8 | if (process.env.ENV === 'production') { | 14 | if (process.env.ENV === 'production') { |
9 | enableProdMode(); | 15 | enableProdMode(); |
10 | } | 16 | } |
11 | 17 | ||
12 | bootstrap(AppComponent, [ provideRouter(routes) ]); | 18 | bootstrap(AppComponent, [ |
19 | HTTP_PROVIDERS, | ||
20 | provide(AuthHttp, { | ||
21 | useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => { | ||
22 | return new AuthHttp(backend, defaultOptions, authService); | ||
23 | }, | ||
24 | deps: [ XHRBackend, RequestOptions, AuthService ] | ||
25 | }), | ||
26 | AuthService, | ||
27 | provideRouter(routes) | ||
28 | ]); | ||