X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Faccount%2Faccount.component.ts;h=57b3d4ccd4c052f1ab674bea3df4990c0514b9fa;hb=09223546a4d882a9dbfdbd95d551e48af7bee123;hp=54939f43bc4ef117804afa1300a59773c63e4cd3;hpb=0f6da32b148c0f4146b2ae9ad1add9a9f00cc339;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/account/account.component.ts b/client/src/app/account/account.component.ts index 54939f43b..57b3d4ccd 100644 --- a/client/src/app/account/account.component.ts +++ b/client/src/app/account/account.component.ts @@ -1,49 +1,28 @@ -import { Validators } from '@angular/common'; import { Component, OnInit } from '@angular/core'; -import { FormControl, FormGroup, REACTIVE_FORM_DIRECTIVES } from '@angular/forms'; +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 ], - directives: [ REACTIVE_FORM_DIRECTIVES ] + templateUrl: './account.component.html', + styleUrls: [ './account.component.scss' ] }) - export class AccountComponent implements OnInit { - newPassword = ''; - newConfirmedPassword = ''; - changePasswordForm: FormGroup; - information: string = null; - error: string = null; + user: User = null; - constructor( - private accountService: AccountService, - private router: Router - ) {} + constructor(private authService: AuthService) {} ngOnInit() { - this.changePasswordForm = new FormGroup({ - 'new-password': new FormControl('', [ Validators.required, Validators.minLength(6) ]), - 'new-confirmed-password': new FormControl('', [ Validators.required, Validators.minLength(6) ]), - }); - } - - changePassword() { - this.information = null; - this.error = null; - - if (this.newPassword !== this.newConfirmedPassword) { - this.error = 'The new password and the confirmed password do not correspond.'; - return; - } - - this.accountService.changePassword(this.newPassword).subscribe( - ok => this.information = 'Password updated.', - - err => this.error = err - ); + this.user = this.authService.getUser(); } }