diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 14:32:15 +0200 |
commit | df98563e2104b82b119c00a3cd83cd0dc1242d25 (patch) | |
tree | a9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/login/login.component.ts | |
parent | 46757b477c1adb5f98060d15998a3852e18902a6 (diff) | |
download | PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip |
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r-- | client/src/app/login/login.component.ts | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index fd4a314cc..77703a80c 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms' |
3 | import { Router } from '@angular/router'; | 3 | import { Router } from '@angular/router' |
4 | 4 | ||
5 | import { AuthService } from '../core'; | 5 | import { AuthService } from '../core' |
6 | import { FormReactive } from '../shared'; | 6 | import { FormReactive } from '../shared' |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'my-login', | 9 | selector: 'my-login', |
@@ -11,60 +11,60 @@ import { FormReactive } from '../shared'; | |||
11 | }) | 11 | }) |
12 | 12 | ||
13 | export class LoginComponent extends FormReactive implements OnInit { | 13 | export class LoginComponent extends FormReactive implements OnInit { |
14 | error: string = null; | 14 | error: string = null |
15 | 15 | ||
16 | form: FormGroup; | 16 | form: FormGroup |
17 | formErrors = { | 17 | formErrors = { |
18 | 'username': '', | 18 | 'username': '', |
19 | 'password': '' | 19 | 'password': '' |
20 | }; | 20 | } |
21 | validationMessages = { | 21 | validationMessages = { |
22 | 'username': { | 22 | 'username': { |
23 | 'required': 'Username is required.', | 23 | 'required': 'Username is required.' |
24 | }, | 24 | }, |
25 | 'password': { | 25 | 'password': { |
26 | 'required': 'Password is required.' | 26 | 'required': 'Password is required.' |
27 | } | 27 | } |
28 | }; | 28 | } |
29 | 29 | ||
30 | constructor( | 30 | constructor ( |
31 | private authService: AuthService, | 31 | private authService: AuthService, |
32 | private formBuilder: FormBuilder, | 32 | private formBuilder: FormBuilder, |
33 | private router: Router | 33 | private router: Router |
34 | ) { | 34 | ) { |
35 | super(); | 35 | super() |
36 | } | 36 | } |
37 | 37 | ||
38 | buildForm() { | 38 | buildForm () { |
39 | this.form = this.formBuilder.group({ | 39 | this.form = this.formBuilder.group({ |
40 | username: [ '', Validators.required ], | 40 | username: [ '', Validators.required ], |
41 | password: [ '', Validators.required ], | 41 | password: [ '', Validators.required ] |
42 | }); | 42 | }) |
43 | 43 | ||
44 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)); | 44 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) |
45 | } | 45 | } |
46 | 46 | ||
47 | ngOnInit() { | 47 | ngOnInit () { |
48 | this.buildForm(); | 48 | this.buildForm() |
49 | } | 49 | } |
50 | 50 | ||
51 | login() { | 51 | login () { |
52 | this.error = null; | 52 | this.error = null |
53 | 53 | ||
54 | const { username, password } = this.form.value; | 54 | const { username, password } = this.form.value |
55 | 55 | ||
56 | this.authService.login(username, password).subscribe( | 56 | this.authService.login(username, password).subscribe( |
57 | result => this.router.navigate(['/videos/list']), | 57 | result => this.router.navigate(['/videos/list']), |
58 | 58 | ||
59 | error => { | 59 | error => { |
60 | console.error(error.json); | 60 | console.error(error.json) |
61 | 61 | ||
62 | if (error.json.error === 'invalid_grant') { | 62 | if (error.json.error === 'invalid_grant') { |
63 | this.error = 'Credentials are invalid.'; | 63 | this.error = 'Credentials are invalid.' |
64 | } else { | 64 | } else { |
65 | this.error = `${error.json.error}: ${error.json.error_description}`; | 65 | this.error = `${error.json.error}: ${error.json.error_description}` |
66 | } | 66 | } |
67 | } | 67 | } |
68 | ); | 68 | ) |
69 | } | 69 | } |
70 | } | 70 | } |