@@ -13,7 +13,7 @@ import { AuthenticationService } from '../../_services/authentication.service';
13
13
selector : 'app-login' ,
14
14
standalone : true ,
15
15
imports : [ RouterLink , FormsModule , InputTextModule , ButtonModule , SelectButtonModule , PasswordModule , ToastModule ] ,
16
- providers : [ MessageService , AuthenticationService ] ,
16
+ providers : [ MessageService ] ,
17
17
templateUrl : './login.component.html' ,
18
18
styleUrl : './account.component.css' ,
19
19
} )
@@ -42,29 +42,26 @@ export class LoginComponent {
42
42
this . isProcessingLogin = true ;
43
43
44
44
// authenticationService returns an observable that we can subscribe to
45
- this . authenticationService
46
- . login ( this . userForm . username , this . userForm . password )
47
- . pipe ( )
48
- . subscribe ( {
49
- next : ( ) => {
50
- // get return url from route parameters or default to '/'
51
- const returnUrl = this . route . snapshot . queryParams [ 'returnUrl' ] || '/' ;
52
- this . router . navigate ( [ returnUrl ] ) ;
53
- } ,
54
- error : error => {
55
- this . isProcessingLogin = false ;
56
- const status = error . cause . status ;
57
- let errorMessage = 'An unknown error occurred' ;
58
- if ( status === 400 ) {
59
- errorMessage = 'Missing Fields' ;
60
- } else if ( status === 401 ) {
61
- errorMessage = 'Invalid username or password' ;
62
- } else if ( status === 500 ) {
63
- errorMessage = 'Internal Server Error' ;
64
- }
65
- this . messageService . add ( { severity : 'error' , summary : 'Log In Error' , detail : errorMessage } ) ;
66
- } ,
67
- } ) ;
45
+ this . authenticationService . login ( this . userForm . username , this . userForm . password ) . subscribe ( {
46
+ next : ( ) => {
47
+ // get return url from route parameters or default to '/'
48
+ const returnUrl = this . route . snapshot . queryParams [ 'returnUrl' ] || '/' ;
49
+ this . router . navigate ( [ returnUrl ] ) ;
50
+ } ,
51
+ error : error => {
52
+ this . isProcessingLogin = false ;
53
+ const status = error . cause . status ;
54
+ let errorMessage = 'An unknown error occurred' ;
55
+ if ( status === 400 ) {
56
+ errorMessage = 'Missing Fields' ;
57
+ } else if ( status === 401 ) {
58
+ errorMessage = 'Invalid username or password' ;
59
+ } else if ( status === 500 ) {
60
+ errorMessage = 'Internal Server Error' ;
61
+ }
62
+ this . messageService . add ( { severity : 'error' , summary : 'Log In Error' , detail : errorMessage } ) ;
63
+ } ,
64
+ } ) ;
68
65
} else {
69
66
console . log ( 'Invalid form' ) ;
70
67
}
0 commit comments