@@ -14,8 +14,7 @@ import { MatSnackBar } from "@angular/material/snack-bar";
1414export class LoginComponent implements OnInit {
1515 form : FormGroup ;
1616 tokenInput : AbstractControl ;
17-
18- redirectUrl = null ;
17+ loggingIn = false ;
1918
2019 constructor (
2120 private snackBar : MatSnackBar ,
@@ -38,8 +37,8 @@ export class LoginComponent implements OnInit {
3837 this . snackBar . dismiss ( ) ;
3938
4039 const state = history . state ;
41- if ( state . referer ) {
42- this . redirectUrl = state . referer ;
40+ if ( state . referer && ! this . authService . redirectUrl ) {
41+ this . authService . redirectUrl = state . referer ;
4342 }
4443 }
4544
@@ -49,6 +48,7 @@ export class LoginComponent implements OnInit {
4948 return ;
5049 }
5150
51+ this . loggingIn = true ;
5252 const tokenValue = this . tokenInput . value ;
5353 const token = `Bearer ${ tokenValue } ` ;
5454
@@ -58,14 +58,18 @@ export class LoginComponent implements OnInit {
5858
5959 this . namespaceTracker . getNamespaces ( ) ;
6060
61- if ( this . redirectUrl ) {
62- this . appRouter . navigateByUrl ( this . redirectUrl ) ;
61+ if ( this . authService . redirectUrl ) {
62+ this . appRouter . navigateByUrl ( this . authService . redirectUrl ) ;
63+ this . authService . redirectUrl = null ;
64+ this . loggingIn = false ;
6365 return ;
6466 }
6567
6668 this . appRouter . navigateToHomePage ( ) ;
69+ this . loggingIn = false ;
6770 } , err => {
6871 this . tokenInput . setErrors ( { error : 'Invalid token' } )
72+ this . loggingIn = false ;
6973 } )
7074 }
7175}
0 commit comments