]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/account/account.component.ts
Client Better design for video watch
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account.component.ts
index 5c42103f878643dc171e1daba7d6be22cc91d72a..57b3d4ccd4c052f1ab674bea3df4990c0514b9fa 100644 (file)
@@ -1,45 +1,28 @@
-import { Control, ControlGroup, Validators } 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 { NotificationsService } from 'angular2-notifications';
+
+import { AuthService } from '../core';
+import {
+  FormReactive,
+  User,
+  UserService,
+  USER_PASSWORD
+} from '../shared';
 
 @Component({
   selector: 'my-account',
-  template: require('./account.component.html'),
-  providers: [ AccountService ]
+  templateUrl: './account.component.html',
+  styleUrls: [ './account.component.scss' ]
 })
-
 export class AccountComponent implements OnInit {
-  changePasswordForm: ControlGroup;
-  information: string = null;
-  error: string = null;
+  user: User = null;
 
-  constructor(
-    private accountService: AccountService,
-    private router: Router
-  ) {}
+  constructor(private authService: AuthService) {}
 
   ngOnInit() {
-    this.changePasswordForm = new ControlGroup({
-      newPassword: new Control('', Validators.compose([ Validators.required, Validators.minLength(6) ])),
-      newConfirmedPassword: new Control('', Validators.compose([ Validators.required, Validators.minLength(6) ])),
-    });
-  }
-
-  changePassword(newPassword: string, newConfirmedPassword: string) {
-    this.information = null;
-    this.error = null;
-
-    if (newPassword !== newConfirmedPassword) {
-      this.error = 'The new password and the confirmed password do not correspond.';
-      return;
-    }
-
-    this.accountService.changePassword(newPassword).subscribe(
-      ok => this.information = 'Password updated.',
-
-      err => this.error = err
-    );
+    this.user = this.authService.getUser();
   }
 }