diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-11-09 16:25:27 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 11:07:56 +0100 |
commit | 5beb89f223539f1e415a976ff104f772526b4d20 (patch) | |
tree | 2164677d16a2965d63499e249aa75ab0e06e3a6c /client/src/app/core/scoped-tokens/scoped-tokens.service.ts | |
parent | afff310e50f2fa8419bb4242470cbde46ab54463 (diff) | |
download | PeerTube-5beb89f223539f1e415a976ff104f772526b4d20.tar.gz PeerTube-5beb89f223539f1e415a976ff104f772526b4d20.tar.zst PeerTube-5beb89f223539f1e415a976ff104f772526b4d20.zip |
refactor scoped token service
Diffstat (limited to 'client/src/app/core/scoped-tokens/scoped-tokens.service.ts')
-rw-r--r-- | client/src/app/core/scoped-tokens/scoped-tokens.service.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/client/src/app/core/scoped-tokens/scoped-tokens.service.ts b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts new file mode 100644 index 000000000..8e3697c31 --- /dev/null +++ b/client/src/app/core/scoped-tokens/scoped-tokens.service.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | import { environment } from '../../../environments/environment' | ||
4 | import { AuthService } from '../auth' | ||
5 | import { ScopedToken } from '@shared/models/users/user-scoped-token' | ||
6 | import { catchError } from 'rxjs/operators' | ||
7 | import { RestExtractor } from '../rest' | ||
8 | |||
9 | @Injectable() | ||
10 | export class ScopedTokensService { | ||
11 | private static BASE_SCOPED_TOKENS_URL = environment.apiUrl + '/api/v1/users/scoped-tokens' | ||
12 | |||
13 | constructor ( | ||
14 | private authHttp: HttpClient, | ||
15 | private restExtractor: RestExtractor | ||
16 | ) {} | ||
17 | |||
18 | getScopedTokens () { | ||
19 | return this.authHttp | ||
20 | .get<ScopedToken>(ScopedTokensService.BASE_SCOPED_TOKENS_URL) | ||
21 | .pipe( | ||
22 | catchError(res => this.restExtractor.handleError(res)) | ||
23 | ) | ||
24 | } | ||
25 | |||
26 | renewScopedTokens () { | ||
27 | return this.authHttp | ||
28 | .post<ScopedToken>(ScopedTokensService.BASE_SCOPED_TOKENS_URL, {}) | ||
29 | .pipe( | ||
30 | catchError(res => this.restExtractor.handleError(res)) | ||
31 | ) | ||
32 | } | ||
33 | } | ||