1 import { Injectable } from '@angular/core';
2 import 'rxjs/add/operator/catch';
3 import 'rxjs/add/operator/map';
5 import { AuthService } from '../../core';
6 import { AuthHttp } from '../auth';
7 import { RestExtractor } from '../rest';
10 export class UserService {
11 static BASE_USERS_URL = '/api/v1/users/';
14 private authHttp: AuthHttp,
15 private authService: AuthService,
16 private restExtractor: RestExtractor
19 checkTokenValidity() {
20 const url = UserService.BASE_USERS_URL + 'me';
22 // AuthHttp will redirect us to the login page if the oken is not valid anymore
23 this.authHttp.get(url).subscribe(() => { ; });
26 changePassword(newPassword: string) {
27 const url = UserService.BASE_USERS_URL + this.authService.getUser().id;
32 return this.authHttp.put(url, body)
33 .map(this.restExtractor.extractDataBool)
34 .catch((res) => this.restExtractor.handleError(res));