]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/account/account.service.ts
Server: assert remoteId and host pair is unique
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account.service.ts
CommitLineData
629d8d6f 1import { Injectable } from '@angular/core';
c16ce1de
C
2import 'rxjs/add/operator/catch';
3import 'rxjs/add/operator/map';
629d8d6f 4
693b1aba
C
5import { AuthService } from '../core';
6import { AuthHttp, RestExtractor } from '../shared';
629d8d6f
C
7
8@Injectable()
9export class AccountService {
10 private static BASE_USERS_URL = '/api/v1/users/';
11
de59c48f
C
12 constructor(
13 private authHttp: AuthHttp,
14 private authService: AuthService,
15 private restExtractor: RestExtractor
16 ) {}
629d8d6f
C
17
18 changePassword(newPassword: string) {
19 const url = AccountService.BASE_USERS_URL + this.authService.getUser().id;
20 const body = {
21 password: newPassword
22 };
23
de59c48f
C
24 return this.authHttp.put(url, body)
25 .map(this.restExtractor.extractDataBool)
26 .catch((res) => this.restExtractor.handleError(res));
629d8d6f
C
27 }
28}