Skip to content

Commit 3dc73f9

Browse files
Properly handle AuthMethod subscription in LogInComponent
1 parent 94ceee9 commit 3dc73f9

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/app/shared/log-in/log-in.component.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
2-
import { Observable } from 'rxjs';
2+
import { map, Observable } from 'rxjs';
33
import { select, Store } from '@ngrx/store';
44
import { AuthMethod } from '../../core/auth/models/auth.method';
55
import {
@@ -35,7 +35,7 @@ export class LogInComponent implements OnInit {
3535
* The list of authentication methods available
3636
* @type {AuthMethod[]}
3737
*/
38-
public authMethods: AuthMethod[];
38+
public authMethods: Observable<AuthMethod[]>;
3939

4040
/**
4141
* Whether user is authenticated.
@@ -55,13 +55,11 @@ export class LogInComponent implements OnInit {
5555
}
5656

5757
ngOnInit(): void {
58-
59-
this.store.pipe(
58+
this.authMethods = this.store.pipe(
6059
select(getAuthenticationMethods),
61-
).subscribe(methods => {
6260
// ignore the ip authentication method when it's returned by the backend
63-
this.authMethods = methods.filter(a => a.authMethodType !== AuthMethodType.Ip);
64-
});
61+
map((methods: AuthMethod[]) => methods.filter((authMethod: AuthMethod) => authMethod.authMethodType !== AuthMethodType.Ip)),
62+
);
6563

6664
// set loading
6765
this.loading = this.store.pipe(select(isAuthenticationLoading));

0 commit comments

Comments
 (0)