From 2b084d7048a2d8a571d601916bdd21cef3a36311 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Mar 2018 18:22:59 +0200 Subject: Add link to register in login form --- client/src/app/login/login.component.ts | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'client/src/app/login/login.component.ts') diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts index 22e8c77dd..f7b49ec45 100644 --- a/client/src/app/login/login.component.ts +++ b/client/src/app/login/login.component.ts @@ -1,6 +1,7 @@ import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' import { FormBuilder, FormGroup, Validators } from '@angular/forms' import { Router } from '@angular/router' +import { RedirectService, ServerService } from '@app/core' import { UserService } from '@app/shared' import { NotificationsService } from 'angular2-notifications' import { ModalDirective } from 'ngx-bootstrap/modal' @@ -34,16 +35,20 @@ export class LoginComponent extends FormReactive implements OnInit { } forgotPasswordEmail = '' - constructor ( - private authService: AuthService, - private userService: UserService, - private notificationsService: NotificationsService, - private formBuilder: FormBuilder, - private router: Router - ) { + constructor (private authService: AuthService, + private userService: UserService, + private serverService: ServerService, + private redirectService: RedirectService, + private notificationsService: NotificationsService, + private formBuilder: FormBuilder, + private router: Router) { super() } + get signupAllowed () { + return this.serverService.getConfig().signup.allowed === true + } + buildForm () { this.form = this.formBuilder.group({ username: [ '', Validators.required ], @@ -62,11 +67,12 @@ export class LoginComponent extends FormReactive implements OnInit { const { username, password } = this.form.value - this.authService.login(username, password).subscribe( - () => this.router.navigate(['/videos/list']), + this.authService.login(username, password) + .subscribe( + () => this.redirectService.redirectToHomepage(), - err => this.error = err.message - ) + err => this.error = err.message + ) } askResetPassword () { -- cgit v1.2.3