diff options
Diffstat (limited to 'client/src/app/login')
-rw-r--r-- | client/src/app/login/index.ts | 6 | ||||
-rw-r--r-- | client/src/app/login/login-routing.module.ts | 8 | ||||
-rw-r--r-- | client/src/app/login/login.component.ts | 50 | ||||
-rw-r--r-- | client/src/app/login/login.module.ts | 8 |
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 @@ | |||
1 | export * from './login-routing.module'; | 1 | export * from './login-routing.module' |
2 | export * from './login.component'; | 2 | export * from './login.component' |
3 | export * from './login.module'; | 3 | export * 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 @@ | |||
1 | import { NgModule } from '@angular/core'; | 1 | import { NgModule } from '@angular/core' |
2 | import { RouterModule, Routes } from '@angular/router'; | 2 | import { RouterModule, Routes } from '@angular/router' |
3 | 3 | ||
4 | import { LoginComponent } from './login.component'; | 4 | import { LoginComponent } from './login.component' |
5 | 5 | ||
6 | const loginRoutes: Routes = [ | 6 | const 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 @@ | |||
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 | } |
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 @@ | |||
1 | import { NgModule } from '@angular/core'; | 1 | import { NgModule } from '@angular/core' |
2 | 2 | ||
3 | import { LoginRoutingModule } from './login-routing.module'; | 3 | import { LoginRoutingModule } from './login-routing.module' |
4 | import { LoginComponent } from './login.component'; | 4 | import { LoginComponent } from './login.component' |
5 | import { SharedModule } from '../shared'; | 5 | import { SharedModule } from '../shared' |
6 | 6 | ||
7 | @NgModule({ | 7 | @NgModule({ |
8 | imports: [ | 8 | imports: [ |