aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/users/user.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/users/user.service.ts')
-rw-r--r--client/src/app/shared/users/user.service.ts40
1 files changed, 25 insertions, 15 deletions
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts
index adb840cec..4843be618 100644
--- a/client/src/app/shared/users/user.service.ts
+++ b/client/src/app/shared/users/user.service.ts
@@ -1,7 +1,6 @@
1import { catchError, map } from 'rxjs/operators'
1import { HttpClient } from '@angular/common/http' 2import { HttpClient } from '@angular/common/http'
2import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
3import 'rxjs/add/operator/catch'
4import 'rxjs/add/operator/map'
5import { UserCreate, UserUpdateMe } from '../../../../../shared' 4import { UserCreate, UserUpdateMe } from '../../../../../shared'
6import { environment } from '../../../environments/environment' 5import { environment } from '../../../environments/environment'
7import { RestExtractor } from '../rest' 6import { RestExtractor } from '../rest'
@@ -13,7 +12,8 @@ export class UserService {
13 constructor ( 12 constructor (
14 private authHttp: HttpClient, 13 private authHttp: HttpClient,
15 private restExtractor: RestExtractor 14 private restExtractor: RestExtractor
16 ) {} 15 ) {
16 }
17 17
18 changePassword (newPassword: string) { 18 changePassword (newPassword: string) {
19 const url = UserService.BASE_USERS_URL + 'me' 19 const url = UserService.BASE_USERS_URL + 'me'
@@ -22,44 +22,52 @@ export class UserService {
22 } 22 }
23 23
24 return this.authHttp.put(url, body) 24 return this.authHttp.put(url, body)
25 .map(this.restExtractor.extractDataBool) 25 .pipe(
26 .catch(res => this.restExtractor.handleError(res)) 26 map(this.restExtractor.extractDataBool),
27 catchError(res => this.restExtractor.handleError(res))
28 )
27 } 29 }
28 30
29 updateMyProfile (profile: UserUpdateMe) { 31 updateMyProfile (profile: UserUpdateMe) {
30 const url = UserService.BASE_USERS_URL + 'me' 32 const url = UserService.BASE_USERS_URL + 'me'
31 33
32 return this.authHttp.put(url, profile) 34 return this.authHttp.put(url, profile)
33 .map(this.restExtractor.extractDataBool) 35 .pipe(
34 .catch(res => this.restExtractor.handleError(res)) 36 map(this.restExtractor.extractDataBool),
37 catchError(res => this.restExtractor.handleError(res))
38 )
35 } 39 }
36 40
37 changeAvatar (avatarForm: FormData) { 41 changeAvatar (avatarForm: FormData) {
38 const url = UserService.BASE_USERS_URL + 'me/avatar/pick' 42 const url = UserService.BASE_USERS_URL + 'me/avatar/pick'
39 43
40 return this.authHttp.post(url, avatarForm) 44 return this.authHttp.post(url, avatarForm)
41 .catch(this.restExtractor.handleError) 45 .pipe(catchError(this.restExtractor.handleError))
42 } 46 }
43 47
44 signup (userCreate: UserCreate) { 48 signup (userCreate: UserCreate) {
45 return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate) 49 return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate)
46 .map(this.restExtractor.extractDataBool) 50 .pipe(
47 .catch(res => this.restExtractor.handleError(res)) 51 map(this.restExtractor.extractDataBool),
52 catchError(res => this.restExtractor.handleError(res))
53 )
48 } 54 }
49 55
50 getMyVideoQuotaUsed () { 56 getMyVideoQuotaUsed () {
51 const url = UserService.BASE_USERS_URL + '/me/video-quota-used' 57 const url = UserService.BASE_USERS_URL + '/me/video-quota-used'
52 58
53 return this.authHttp.get(url) 59 return this.authHttp.get(url)
54 .catch(res => this.restExtractor.handleError(res)) 60 .pipe(catchError(res => this.restExtractor.handleError(res)))
55 } 61 }
56 62
57 askResetPassword (email: string) { 63 askResetPassword (email: string) {
58 const url = UserService.BASE_USERS_URL + '/ask-reset-password' 64 const url = UserService.BASE_USERS_URL + '/ask-reset-password'
59 65
60 return this.authHttp.post(url, { email }) 66 return this.authHttp.post(url, { email })
61 .map(this.restExtractor.extractDataBool) 67 .pipe(
62 .catch(res => this.restExtractor.handleError(res)) 68 map(this.restExtractor.extractDataBool),
69 catchError(res => this.restExtractor.handleError(res))
70 )
63 } 71 }
64 72
65 resetPassword (userId: number, verificationString: string, password: string) { 73 resetPassword (userId: number, verificationString: string, password: string) {
@@ -70,7 +78,9 @@ export class UserService {
70 } 78 }
71 79
72 return this.authHttp.post(url, body) 80 return this.authHttp.post(url, body)
73 .map(this.restExtractor.extractDataBool) 81 .pipe(
74 .catch(res => this.restExtractor.handleError(res)) 82 map(this.restExtractor.extractDataBool),
83 catchError(res => this.restExtractor.handleError(res))
84 )
75 } 85 }
76} 86}