aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/login/login.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-23 14:37:49 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-23 14:37:49 +0200
commit0f6da32b148c0f4146b2ae9ad1add9a9f00cc339 (patch)
tree1272a5892e357aa0a0d370545effa6800092d568 /client/src/app/login/login.component.ts
parent39f87cb21689a912559d0498641db7d2de4a784d (diff)
downloadPeerTube-0f6da32b148c0f4146b2ae9ad1add9a9f00cc339.tar.gz
PeerTube-0f6da32b148c0f4146b2ae9ad1add9a9f00cc339.tar.zst
PeerTube-0f6da32b148c0f4146b2ae9ad1add9a9f00cc339.zip
Client: update to new form api
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r--client/src/app/login/login.component.ts23
1 files changed, 18 insertions, 5 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts
index ddd62462e..fe867b7b4 100644
--- a/client/src/app/login/login.component.ts
+++ b/client/src/app/login/login.component.ts
@@ -1,23 +1,36 @@
1import { Component } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
2import { Validators } from '@angular/common';
3import { FormControl, FormGroup, REACTIVE_FORM_DIRECTIVES } from '@angular/forms';
2import { Router } from '@angular/router'; 4import { Router } from '@angular/router';
3 5
4import { AuthService } from '../shared'; 6import { AuthService } from '../shared';
5 7
6@Component({ 8@Component({
7 selector: 'my-login', 9 selector: 'my-login',
8 template: require('./login.component.html') 10 template: require('./login.component.html'),
11 directives: [ REACTIVE_FORM_DIRECTIVES ]
9}) 12})
10 13
11export class LoginComponent { 14export class LoginComponent implements OnInit {
12 error: string = null; 15 error: string = null;
16 username = '';
17 password: '';
18 loginForm: FormGroup;
13 19
14 constructor( 20 constructor(
15 private authService: AuthService, 21 private authService: AuthService,
16 private router: Router 22 private router: Router
17 ) {} 23 ) {}
18 24
19 login(username: string, password: string) { 25 ngOnInit() {
20 this.authService.login(username, password).subscribe( 26 this.loginForm = new FormGroup({
27 username: new FormControl('', [ <any>Validators.required ]),
28 password: new FormControl('', [ <any>Validators.required ]),
29 });
30 }
31
32 login() {
33 this.authService.login(this.username, this.password).subscribe(
21 result => { 34 result => {
22 this.error = null; 35 this.error = null;
23 36