diff options
Diffstat (limited to 'client/src/app/core/users/user.service.ts')
-rw-r--r-- | client/src/app/core/users/user.service.ts | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts index a6a0474ab..f173c356a 100644 --- a/client/src/app/core/users/user.service.ts +++ b/client/src/app/core/users/user.service.ts | |||
@@ -49,10 +49,7 @@ export class UserService { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | return this.authHttp.put(url, body) | 51 | return this.authHttp.put(url, body) |
52 | .pipe( | 52 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
53 | map(this.restExtractor.extractDataBool), | ||
54 | catchError(err => this.restExtractor.handleError(err)) | ||
55 | ) | ||
56 | } | 53 | } |
57 | 54 | ||
58 | changeEmail (password: string, newEmail: string) { | 55 | changeEmail (password: string, newEmail: string) { |
@@ -63,10 +60,7 @@ export class UserService { | |||
63 | } | 60 | } |
64 | 61 | ||
65 | return this.authHttp.put(url, body) | 62 | return this.authHttp.put(url, body) |
66 | .pipe( | 63 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
67 | map(this.restExtractor.extractDataBool), | ||
68 | catchError(err => this.restExtractor.handleError(err)) | ||
69 | ) | ||
70 | } | 64 | } |
71 | 65 | ||
72 | // --------------------------------------------------------------------------- | 66 | // --------------------------------------------------------------------------- |
@@ -90,20 +84,14 @@ export class UserService { | |||
90 | const url = UserService.BASE_USERS_URL + 'me' | 84 | const url = UserService.BASE_USERS_URL + 'me' |
91 | 85 | ||
92 | return this.authHttp.put(url, profile) | 86 | return this.authHttp.put(url, profile) |
93 | .pipe( | 87 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
94 | map(this.restExtractor.extractDataBool), | ||
95 | catchError(err => this.restExtractor.handleError(err)) | ||
96 | ) | ||
97 | } | 88 | } |
98 | 89 | ||
99 | deleteMe () { | 90 | deleteMe () { |
100 | const url = UserService.BASE_USERS_URL + 'me' | 91 | const url = UserService.BASE_USERS_URL + 'me' |
101 | 92 | ||
102 | return this.authHttp.delete(url) | 93 | return this.authHttp.delete(url) |
103 | .pipe( | 94 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
104 | map(this.restExtractor.extractDataBool), | ||
105 | catchError(err => this.restExtractor.handleError(err)) | ||
106 | ) | ||
107 | } | 95 | } |
108 | 96 | ||
109 | changeAvatar (avatarForm: FormData) { | 97 | changeAvatar (avatarForm: FormData) { |
@@ -117,16 +105,12 @@ export class UserService { | |||
117 | const url = UserService.BASE_USERS_URL + 'me/avatar' | 105 | const url = UserService.BASE_USERS_URL + 'me/avatar' |
118 | 106 | ||
119 | return this.authHttp.delete(url) | 107 | return this.authHttp.delete(url) |
120 | .pipe( | 108 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
121 | map(this.restExtractor.extractDataBool), | ||
122 | catchError(err => this.restExtractor.handleError(err)) | ||
123 | ) | ||
124 | } | 109 | } |
125 | 110 | ||
126 | signup (userCreate: UserRegister) { | 111 | signup (userCreate: UserRegister) { |
127 | return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate) | 112 | return this.authHttp.post(UserService.BASE_USERS_URL + 'register', userCreate) |
128 | .pipe( | 113 | .pipe( |
129 | map(this.restExtractor.extractDataBool), | ||
130 | tap(() => this.signupInThisSession = true), | 114 | tap(() => this.signupInThisSession = true), |
131 | catchError(err => this.restExtractor.handleError(err)) | 115 | catchError(err => this.restExtractor.handleError(err)) |
132 | ) | 116 | ) |
@@ -143,10 +127,7 @@ export class UserService { | |||
143 | const url = UserService.BASE_USERS_URL + '/ask-reset-password' | 127 | const url = UserService.BASE_USERS_URL + '/ask-reset-password' |
144 | 128 | ||
145 | return this.authHttp.post(url, { email }) | 129 | return this.authHttp.post(url, { email }) |
146 | .pipe( | 130 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
147 | map(this.restExtractor.extractDataBool), | ||
148 | catchError(err => this.restExtractor.handleError(err)) | ||
149 | ) | ||
150 | } | 131 | } |
151 | 132 | ||
152 | resetPassword (userId: number, verificationString: string, password: string) { | 133 | resetPassword (userId: number, verificationString: string, password: string) { |
@@ -157,10 +138,7 @@ export class UserService { | |||
157 | } | 138 | } |
158 | 139 | ||
159 | return this.authHttp.post(url, body) | 140 | return this.authHttp.post(url, body) |
160 | .pipe( | 141 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
161 | map(this.restExtractor.extractDataBool), | ||
162 | catchError(res => this.restExtractor.handleError(res)) | ||
163 | ) | ||
164 | } | 142 | } |
165 | 143 | ||
166 | verifyEmail (userId: number, verificationString: string, isPendingEmail: boolean) { | 144 | verifyEmail (userId: number, verificationString: string, isPendingEmail: boolean) { |
@@ -171,20 +149,14 @@ export class UserService { | |||
171 | } | 149 | } |
172 | 150 | ||
173 | return this.authHttp.post(url, body) | 151 | return this.authHttp.post(url, body) |
174 | .pipe( | 152 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
175 | map(this.restExtractor.extractDataBool), | ||
176 | catchError(res => this.restExtractor.handleError(res)) | ||
177 | ) | ||
178 | } | 153 | } |
179 | 154 | ||
180 | askSendVerifyEmail (email: string) { | 155 | askSendVerifyEmail (email: string) { |
181 | const url = UserService.BASE_USERS_URL + '/ask-send-verify-email' | 156 | const url = UserService.BASE_USERS_URL + '/ask-send-verify-email' |
182 | 157 | ||
183 | return this.authHttp.post(url, { email }) | 158 | return this.authHttp.post(url, { email }) |
184 | .pipe( | 159 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
185 | map(this.restExtractor.extractDataBool), | ||
186 | catchError(err => this.restExtractor.handleError(err)) | ||
187 | ) | ||
188 | } | 160 | } |
189 | 161 | ||
190 | autocomplete (search: string): Observable<string[]> { | 162 | autocomplete (search: string): Observable<string[]> { |
@@ -216,18 +188,12 @@ export class UserService { | |||
216 | 188 | ||
217 | addUser (userCreate: UserCreate) { | 189 | addUser (userCreate: UserCreate) { |
218 | return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) | 190 | return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) |
219 | .pipe( | 191 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
220 | map(this.restExtractor.extractDataBool), | ||
221 | catchError(err => this.restExtractor.handleError(err)) | ||
222 | ) | ||
223 | } | 192 | } |
224 | 193 | ||
225 | updateUser (userId: number, userUpdate: UserUpdate) { | 194 | updateUser (userId: number, userUpdate: UserUpdate) { |
226 | return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate) | 195 | return this.authHttp.put(UserService.BASE_USERS_URL + userId, userUpdate) |
227 | .pipe( | 196 | .pipe(catchError(err => this.restExtractor.handleError(err))) |
228 | map(this.restExtractor.extractDataBool), | ||
229 | catchError(err => this.restExtractor.handleError(err)) | ||
230 | ) | ||
231 | } | 197 | } |
232 | 198 | ||
233 | updateUsers (users: UserServerModel[], userUpdate: UserUpdate) { | 199 | updateUsers (users: UserServerModel[], userUpdate: UserUpdate) { |