aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/login/login.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/login/login.component.ts')
-rw-r--r--client/src/app/login/login.component.ts34
1 files changed, 7 insertions, 27 deletions
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts
index a14cb2eb7..f7aad06e8 100644
--- a/client/src/app/login/login.component.ts
+++ b/client/src/app/login/login.component.ts
@@ -1,6 +1,4 @@
1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' 1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
2import { FormBuilder, FormGroup, Validators } from '@angular/forms'
3import { Router } from '@angular/router'
4import { RedirectService, ServerService } from '@app/core' 2import { RedirectService, ServerService } from '@app/core'
5import { UserService } from '@app/shared' 3import { UserService } from '@app/shared'
6import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
@@ -8,6 +6,8 @@ import { ModalDirective } from 'ngx-bootstrap/modal'
8import { AuthService } from '../core' 6import { AuthService } from '../core'
9import { FormReactive } from '../shared' 7import { FormReactive } from '../shared'
10import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
10import { LOGIN_PASSWORD, LOGIN_USERNAME } from '@app/shared/forms/form-validators/login'
11 11
12@Component({ 12@Component({
13 selector: 'my-login', 13 selector: 'my-login',
@@ -20,29 +20,15 @@ export class LoginComponent extends FormReactive implements OnInit {
20 @ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef 20 @ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef
21 21
22 error: string = null 22 error: string = null
23
24 form: FormGroup
25 formErrors = {
26 'username': '',
27 'password': ''
28 }
29 validationMessages = {
30 'username': {
31 'required': 'Username is required.'
32 },
33 'password': {
34 'required': 'Password is required.'
35 }
36 }
37 forgotPasswordEmail = '' 23 forgotPasswordEmail = ''
38 24
39 constructor ( 25 constructor (
26 protected formValidatorService: FormValidatorService,
40 private authService: AuthService, 27 private authService: AuthService,
41 private userService: UserService, 28 private userService: UserService,
42 private serverService: ServerService, 29 private serverService: ServerService,
43 private redirectService: RedirectService, 30 private redirectService: RedirectService,
44 private notificationsService: NotificationsService, 31 private notificationsService: NotificationsService,
45 private formBuilder: FormBuilder,
46 private i18n: I18n 32 private i18n: I18n
47 ) { 33 ) {
48 super() 34 super()
@@ -52,17 +38,11 @@ export class LoginComponent extends FormReactive implements OnInit {
52 return this.serverService.getConfig().signup.allowed === true 38 return this.serverService.getConfig().signup.allowed === true
53 } 39 }
54 40
55 buildForm () {
56 this.form = this.formBuilder.group({
57 username: [ '', Validators.required ],
58 password: [ '', Validators.required ]
59 })
60
61 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
62 }
63
64 ngOnInit () { 41 ngOnInit () {
65 this.buildForm() 42 this.buildForm({
43 username: LOGIN_USERNAME,
44 password: LOGIN_PASSWORD
45 })
66 } 46 }
67 47
68 login () { 48 login () {