aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/login
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
commitdf98563e2104b82b119c00a3cd83cd0dc1242d25 (patch)
treea9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/login
parent46757b477c1adb5f98060d15998a3852e18902a6 (diff)
downloadPeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/login')
-rw-r--r--client/src/app/login/index.ts6
-rw-r--r--client/src/app/login/login-routing.module.ts8
-rw-r--r--client/src/app/login/login.component.ts50
-rw-r--r--client/src/app/login/login.module.ts8
4 files changed, 36 insertions, 36 deletions
diff --git a/client/src/app/login/index.ts b/client/src/app/login/index.ts
index 5639915f7..f1301d8b5 100644
--- a/client/src/app/login/index.ts
+++ b/client/src/app/login/index.ts
@@ -1,3 +1,3 @@
1export * from './login-routing.module'; 1export * from './login-routing.module'
2export * from './login.component'; 2export * from './login.component'
3export * from './login.module'; 3export * from './login.module'
diff --git a/client/src/app/login/login-routing.module.ts b/client/src/app/login/login-routing.module.ts
index 371993884..1a91677c0 100644
--- a/client/src/app/login/login-routing.module.ts
+++ b/client/src/app/login/login-routing.module.ts
@@ -1,7 +1,7 @@
1import { NgModule } from '@angular/core'; 1import { NgModule } from '@angular/core'
2import { RouterModule, Routes } from '@angular/router'; 2import { RouterModule, Routes } from '@angular/router'
3 3
4import { LoginComponent } from './login.component'; 4import { LoginComponent } from './login.component'
5 5
6const loginRoutes: Routes = [ 6const loginRoutes: Routes = [
7 { 7 {
@@ -13,7 +13,7 @@ const loginRoutes: Routes = [
13 } 13 }
14 } 14 }
15 } 15 }
16]; 16]
17 17
18@NgModule({ 18@NgModule({
19 imports: [ RouterModule.forChild(loginRoutes) ], 19 imports: [ RouterModule.forChild(loginRoutes) ],
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 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 2import { FormBuilder, FormGroup, Validators } from '@angular/forms'
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router'
4 4
5import { AuthService } from '../core'; 5import { AuthService } from '../core'
6import { FormReactive } from '../shared'; 6import { 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
13export class LoginComponent extends FormReactive implements OnInit { 13export 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}
diff --git a/client/src/app/login/login.module.ts b/client/src/app/login/login.module.ts
index 31a723b43..1de72dbaa 100644
--- a/client/src/app/login/login.module.ts
+++ b/client/src/app/login/login.module.ts
@@ -1,8 +1,8 @@
1import { NgModule } from '@angular/core'; 1import { NgModule } from '@angular/core'
2 2
3import { LoginRoutingModule } from './login-routing.module'; 3import { LoginRoutingModule } from './login-routing.module'
4import { LoginComponent } from './login.component'; 4import { LoginComponent } from './login.component'
5import { SharedModule } from '../shared'; 5import { SharedModule } from '../shared'
6 6
7@NgModule({ 7@NgModule({
8 imports: [ 8 imports: [