]>
Commit | Line | Data |
---|---|---|
629d8d6f C |
1 | import { Injectable } from '@angular/core'; |
2 | ||
693b1aba C |
3 | import { AuthService } from '../core'; |
4 | import { AuthHttp, RestExtractor } from '../shared'; | |
629d8d6f C |
5 | |
6 | @Injectable() | |
7 | export class AccountService { | |
8 | private static BASE_USERS_URL = '/api/v1/users/'; | |
9 | ||
de59c48f C |
10 | constructor( |
11 | private authHttp: AuthHttp, | |
12 | private authService: AuthService, | |
13 | private restExtractor: RestExtractor | |
14 | ) {} | |
629d8d6f C |
15 | |
16 | changePassword(newPassword: string) { | |
17 | const url = AccountService.BASE_USERS_URL + this.authService.getUser().id; | |
18 | const body = { | |
19 | password: newPassword | |
20 | }; | |
21 | ||
de59c48f C |
22 | return this.authHttp.put(url, body) |
23 | .map(this.restExtractor.extractDataBool) | |
24 | .catch((res) => this.restExtractor.handleError(res)); | |
629d8d6f C |
25 | } |
26 | } |