@@ -6,37 +6,33 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
6
import { InputTextModule } from 'primeng/inputtext' ;
7
7
import { ButtonModule } from 'primeng/button' ;
8
8
9
-
10
9
import { AuthService } from '@blueprint/service/auth/auth.service' ;
11
10
import { SparqlService } from '@blueprint/service/sparql/sparql.service' ;
12
11
13
- import { LogoComponent } from "../core/layout/logo/logo.component" ;
14
12
import { BrandLogoComponent } from "../core/layout/brand-logo/brand-logo.component" ;
15
13
import { MessageChannelService } from '../core/service/message-channel/message-channel.service' ;
16
14
17
-
18
15
@Component ( {
19
16
standalone : true ,
20
17
templateUrl : './login.component.html' ,
21
18
styleUrls : [ './login.component.scss' ] ,
22
19
imports : [
23
- ReactiveFormsModule ,
24
- LogoComponent ,
20
+ ReactiveFormsModule , //
25
21
InputTextModule ,
26
22
ButtonModule ,
27
23
BrandLogoComponent
28
24
]
29
25
} )
30
26
export class LoginComponent implements OnInit {
31
- private readonly destroyRef = inject ( DestroyRef ) ;
27
+ readonly # destroyRef = inject ( DestroyRef ) ;
32
28
33
- private readonly router = inject ( Router ) ;
34
- private readonly route = inject ( ActivatedRoute ) ;
29
+ readonly # router = inject ( Router ) ;
30
+ readonly # route = inject ( ActivatedRoute ) ;
35
31
36
- private readonly messageChannel = inject ( MessageChannelService ) ;
32
+ readonly # messageChannel = inject ( MessageChannelService ) ;
37
33
38
- private readonly authService = inject ( AuthService ) ;
39
- private readonly sparqlService = inject ( SparqlService ) ;
34
+ readonly # authService = inject ( AuthService ) ;
35
+ readonly # sparqlService = inject ( SparqlService ) ;
40
36
41
37
loginForm = new FormGroup ( {
42
38
username : new FormControl < string > ( '' , [ Validators . required ] ) ,
@@ -47,33 +43,37 @@ export class LoginComponent implements OnInit {
47
43
returnUrl = '' ;
48
44
49
45
ngOnInit ( ) : void {
50
- if ( this . authService . isAuthenticated ( ) ) {
51
- this . router . navigate ( [ 'search' ] ) ;
46
+ if ( this . # authService. isAuthenticated ( ) ) {
47
+ this . # router. navigate ( [ 'search' ] ) ;
52
48
return ;
53
49
}
54
- this . returnUrl = this . route . snapshot . queryParams [ 'returnUrl' ] || '/' ;
55
- this . loginForm . valueChanges . pipe ( takeUntilDestroyed ( this . destroyRef ) ) . subscribe ( ( ) => this . errorMessage = '' ) ;
50
+ this . returnUrl = this . #route. snapshot . queryParams [ 'returnUrl' ] || '/' ;
51
+
52
+ this . loginForm . valueChanges . pipe (
53
+ takeUntilDestroyed ( this . #destroyRef)
54
+ ) . subscribe ( ( ) => this . errorMessage = '' ) ;
56
55
}
57
56
58
57
onSubmit ( ) : void {
59
58
const credentials = {
60
59
username : this . loginForm . controls . username . value ?? '' ,
61
60
password : this . loginForm . controls . password . value ?? ''
62
61
} ;
63
- this . authService . updateCredentials ( credentials ) ;
62
+ this . # authService. updateCredentials ( credentials ) ;
64
63
65
- this . sparqlService
64
+ this . # sparqlService
66
65
. select ( 'SELECT * WHERE { ?s ?p ?o . } LIMIT 1' )
67
66
. subscribe ( {
68
67
next : ( ) => {
69
- this . messageChannel . debug ( 'Login successful' ) ;
70
- this . router . navigateByUrl ( this . returnUrl ) ;
68
+ this . # messageChannel. debug ( 'Login successful' ) ;
69
+ this . # router. navigateByUrl ( this . returnUrl ) ;
71
70
} ,
72
71
error : ( ) => {
73
72
this . errorMessage = 'Wrong username or password' ;
74
- this . messageChannel . debug ( 'Wrong username or password' ) ;
73
+ this . #authService. clear ( ) ;
74
+ this . #messageChannel. debug ( 'Wrong username or password' ) ;
75
75
} ,
76
- complete : ( ) => this . messageChannel . debug ( 'Login Test SPARQL Query completed' )
76
+ complete : ( ) => this . # messageChannel. debug ( 'Login Test SPARQL Query completed' )
77
77
78
78
}
79
79
) ;
0 commit comments