]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/account/account.service.ts
Client: split in angular modules
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account.service.ts
1 import { Injectable } from '@angular/core';
2
3 import { AuthService } from '../core';
4 import { AuthHttp, RestExtractor } from '../shared';
5
6 @Injectable()
7 export class AccountService {
8 private static BASE_USERS_URL = '/api/v1/users/';
9
10 constructor(
11 private authHttp: AuthHttp,
12 private authService: AuthService,
13 private restExtractor: RestExtractor
14 ) {}
15
16 changePassword(newPassword: string) {
17 const url = AccountService.BASE_USERS_URL + this.authService.getUser().id;
18 const body = {
19 password: newPassword
20 };
21
22 return this.authHttp.put(url, body)
23 .map(this.restExtractor.extractDataBool)
24 .catch((res) => this.restExtractor.handleError(res));
25 }
26 }