]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/account/account.component.ts
Client: check token valitidy at startup
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account.component.ts
index b503406c93f2b5e4299302cf1d755de093fb01e4..14452a73eccbdeacb406c1ab6eb87d7f667bc40d 100644 (file)
@@ -1,18 +1,17 @@
-import {  } from '@angular/common';
 import { Component, OnInit } from '@angular/core';
 import { FormBuilder, FormGroup } from '@angular/forms';
 import { Router } from '@angular/router';
 
-import { AccountService } from './account.service';
-import { FormReactive, USER_PASSWORD } from '../shared';
+import { NotificationsService } from 'angular2-notifications';
+
+import { FormReactive, UserService, USER_PASSWORD } from '../shared';
 
 @Component({
   selector: 'my-account',
-  template: require('./account.component.html')
+  templateUrl: './account.component.html'
 })
 
 export class AccountComponent extends FormReactive implements OnInit {
-  information: string = null;
   error: string = null;
 
   form: FormGroup;
@@ -26,9 +25,10 @@ export class AccountComponent extends FormReactive implements OnInit {
   };
 
   constructor(
-    private accountService: AccountService,
     private formBuilder: FormBuilder,
-    private router: Router
+    private router: Router,
+    private notificationsService: NotificationsService,
+    private userService: UserService
   ) {
     super();
   }
@@ -50,7 +50,6 @@ export class AccountComponent extends FormReactive implements OnInit {
     const newPassword = this.form.value['new-password'];
     const newConfirmedPassword = this.form.value['new-confirmed-password'];
 
-    this.information = null;
     this.error = null;
 
     if (newPassword !== newConfirmedPassword) {
@@ -58,8 +57,8 @@ export class AccountComponent extends FormReactive implements OnInit {
       return;
     }
 
-    this.accountService.changePassword(newPassword).subscribe(
-      ok => this.information = 'Password updated.',
+    this.userService.changePassword(newPassword).subscribe(
+      () => this.notificationsService.success('Success', 'Password updated.'),
 
       err => this.error = err
     );