]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/login/login.component.ts
Redirect to the last url on login
[github/Chocobozzz/PeerTube.git] / client / src / app / login / login.component.ts
index 7553e64564220907cf323ed7c88f1279893d28c5..18f8f69e57ec5f396d7a7c7aceaf8b98179e91c9 100644 (file)
@@ -19,7 +19,6 @@ import { Router } from '@angular/router'
 export class LoginComponent extends FormReactive implements OnInit {
   @ViewChild('emailInput') input: ElementRef
   @ViewChild('forgotPasswordModal') forgotPasswordModal: ElementRef
-  @ViewChild('forgotPasswordEmailInput') forgotPasswordEmailInput: ElementRef
 
   error: string = null
   forgotPasswordEmail = ''
@@ -45,6 +44,10 @@ export class LoginComponent extends FormReactive implements OnInit {
     return this.serverService.getConfig().signup.allowed === true
   }
 
+  isEmailDisabled () {
+    return this.serverService.getConfig().email.enabled === false
+  }
+
   ngOnInit () {
     this.buildForm({
       username: this.loginValidatorsService.LOGIN_USERNAME,
@@ -61,7 +64,7 @@ export class LoginComponent extends FormReactive implements OnInit {
 
     this.authService.login(username, password)
       .subscribe(
-        () => this.redirect(),
+        () => this.redirectService.redirectToPreviousRoute(),
 
         err => {
           if (err.message.indexOf('credentials are invalid') !== -1) this.error = this.i18n('Incorrect username or password.')
@@ -71,15 +74,6 @@ export class LoginComponent extends FormReactive implements OnInit {
       )
   }
 
-  redirect () {
-    const redirect = this.authService.redirectUrl
-    if (redirect) {
-      this.router.navigate([ redirect ])
-    } else {
-      this.redirectService.redirectToHomepage()
-    }
-  }
-
   askResetPassword () {
     this.userService.askResetPassword(this.forgotPasswordEmail)
       .subscribe(
@@ -96,10 +90,6 @@ export class LoginComponent extends FormReactive implements OnInit {
       )
   }
 
-  onForgotPasswordModalShown () {
-    this.forgotPasswordEmailInput.nativeElement.focus()
-  }
-
   openForgotPasswordModal () {
     this.openedForgotPasswordModal = this.modalService.open(this.forgotPasswordModal)
   }