]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/login/login.component.ts
Only use account name in routes
[github/Chocobozzz/PeerTube.git] / client / src / app / login / login.component.ts
index 22e8c77dd44f4817c6367e5937c80732d6d882ac..2514faf94f6662582b3fbcca1388a0cae8f8a8b7 100644 (file)
@@ -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,19 @@ 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) {
     super()
   }
 
+  get signupAllowed () {
+    return this.serverService.getConfig().signup.allowed === true
+  }
+
   buildForm () {
     this.form = this.formBuilder.group({
       username: [ '', Validators.required ],
@@ -62,11 +66,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 () {