X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Faccount%2Faccount.component.ts;h=929934f67adad77b38506205b0170e9cb86d2eb9;hb=a685e25ca05f08ad1b3f7fbaccc8744727bd8d27;hp=a22738d3f509a6ce011db8a7140ea923ff22c266;hpb=ab32b0fc805b92c5a1d7ac5901cb1a38e94622ca;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/account/account.component.ts b/client/src/app/account/account.component.ts index a22738d3f..929934f67 100644 --- a/client/src/app/account/account.component.ts +++ b/client/src/app/account/account.component.ts @@ -1,47 +1,28 @@ -import { } from '@angular/common'; -import { Component, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { Router } from '@angular/router'; +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') + templateUrl: './account.component.html', + styleUrls: [ './account.component.scss' ] }) - export class AccountComponent implements OnInit { - newPassword = ''; - newConfirmedPassword = ''; - changePasswordForm: FormGroup; - information: string = null; - error: string = null; - - constructor( - private accountService: AccountService, - private router: Router - ) {} - - 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; - } + user: User = null - this.accountService.changePassword(this.newPassword).subscribe( - ok => this.information = 'Password updated.', + constructor (private authService: AuthService) {} - err => this.error = err - ); + ngOnInit () { + this.user = this.authService.getUser() } }