diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
commit | df98563e2104b82b119c00a3cd83cd0dc1242d25 (patch) | |
tree | a9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/shared/users/user.service.ts | |
parent | 46757b477c1adb5f98060d15998a3852e18902a6 (diff) | |
download | PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip |
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/shared/users/user.service.ts')
-rw-r--r-- | client/src/app/shared/users/user.service.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index f1265be0a..e956df5b1 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts | |||
@@ -1,58 +1,58 @@ | |||
1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core' |
2 | import { Http } from '@angular/http'; | 2 | import { Http } from '@angular/http' |
3 | import 'rxjs/add/operator/catch'; | 3 | import 'rxjs/add/operator/catch' |
4 | import 'rxjs/add/operator/map'; | 4 | import 'rxjs/add/operator/map' |
5 | 5 | ||
6 | import { AuthService } from '../../core'; | 6 | import { AuthService } from '../../core' |
7 | import { AuthHttp } from '../auth'; | 7 | import { AuthHttp } from '../auth' |
8 | import { RestExtractor } from '../rest'; | 8 | import { RestExtractor } from '../rest' |
9 | 9 | ||
10 | @Injectable() | 10 | @Injectable() |
11 | export class UserService { | 11 | export class UserService { |
12 | static BASE_USERS_URL = API_URL + '/api/v1/users/'; | 12 | static BASE_USERS_URL = API_URL + '/api/v1/users/' |
13 | 13 | ||
14 | constructor( | 14 | constructor ( |
15 | private http: Http, | 15 | private http: Http, |
16 | private authHttp: AuthHttp, | 16 | private authHttp: AuthHttp, |
17 | private authService: AuthService, | 17 | private authService: AuthService, |
18 | private restExtractor: RestExtractor | 18 | private restExtractor: RestExtractor |
19 | ) {} | 19 | ) {} |
20 | 20 | ||
21 | checkTokenValidity() { | 21 | checkTokenValidity () { |
22 | const url = UserService.BASE_USERS_URL + 'me'; | 22 | const url = UserService.BASE_USERS_URL + 'me' |
23 | 23 | ||
24 | // AuthHttp will redirect us to the login page if the oken is not valid anymore | 24 | // AuthHttp will redirect us to the login page if the oken is not valid anymore |
25 | this.authHttp.get(url).subscribe(() => { ; }); | 25 | this.authHttp.get(url).subscribe() |
26 | } | 26 | } |
27 | 27 | ||
28 | changePassword(newPassword: string) { | 28 | changePassword (newPassword: string) { |
29 | const url = UserService.BASE_USERS_URL + this.authService.getUser().id; | 29 | const url = UserService.BASE_USERS_URL + this.authService.getUser().id |
30 | const body = { | 30 | const body = { |
31 | password: newPassword | 31 | password: newPassword |
32 | }; | 32 | } |
33 | 33 | ||
34 | return this.authHttp.put(url, body) | 34 | return this.authHttp.put(url, body) |
35 | .map(this.restExtractor.extractDataBool) | 35 | .map(this.restExtractor.extractDataBool) |
36 | .catch((res) => this.restExtractor.handleError(res)); | 36 | .catch((res) => this.restExtractor.handleError(res)) |
37 | } | 37 | } |
38 | 38 | ||
39 | updateDetails(details: { displayNSFW: boolean }) { | 39 | updateDetails (details: { displayNSFW: boolean }) { |
40 | const url = UserService.BASE_USERS_URL + this.authService.getUser().id; | 40 | const url = UserService.BASE_USERS_URL + this.authService.getUser().id |
41 | 41 | ||
42 | return this.authHttp.put(url, details) | 42 | return this.authHttp.put(url, details) |
43 | .map(this.restExtractor.extractDataBool) | 43 | .map(this.restExtractor.extractDataBool) |
44 | .catch((res) => this.restExtractor.handleError(res)); | 44 | .catch((res) => this.restExtractor.handleError(res)) |
45 | } | 45 | } |
46 | 46 | ||
47 | signup(username: string, password: string, email: string) { | 47 | signup (username: string, password: string, email: string) { |
48 | const body = { | 48 | const body = { |
49 | username, | 49 | username, |
50 | email, | 50 | email, |
51 | password | 51 | password |
52 | }; | 52 | } |
53 | 53 | ||
54 | return this.http.post(UserService.BASE_USERS_URL + 'register', body) | 54 | return this.http.post(UserService.BASE_USERS_URL + 'register', body) |
55 | .map(this.restExtractor.extractDataBool) | 55 | .map(this.restExtractor.extractDataBool) |
56 | .catch(this.restExtractor.handleError); | 56 | .catch(this.restExtractor.handleError) |
57 | } | 57 | } |
58 | } | 58 | } |