Skip to content

Commit

Permalink
Properly handle AuthMethod subscription in LogInComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Aug 2, 2023
1 parent 94ceee9 commit 3dc73f9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/app/shared/log-in/log-in.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { map, Observable } from 'rxjs';
import { select, Store } from '@ngrx/store';
import { AuthMethod } from '../../core/auth/models/auth.method';
import {
Expand Down Expand Up @@ -35,7 +35,7 @@ export class LogInComponent implements OnInit {
* The list of authentication methods available
* @type {AuthMethod[]}
*/
public authMethods: AuthMethod[];
public authMethods: Observable<AuthMethod[]>;

/**
* Whether user is authenticated.
Expand All @@ -55,13 +55,11 @@ export class LogInComponent implements OnInit {
}

ngOnInit(): void {

this.store.pipe(
this.authMethods = this.store.pipe(
select(getAuthenticationMethods),
).subscribe(methods => {
// ignore the ip authentication method when it's returned by the backend
this.authMethods = methods.filter(a => a.authMethodType !== AuthMethodType.Ip);
});
map((methods: AuthMethod[]) => methods.filter((authMethod: AuthMethod) => authMethod.authMethodType !== AuthMethodType.Ip)),
);

// set loading
this.loading = this.store.pipe(select(isAuthenticationLoading));
Expand Down

0 comments on commit 3dc73f9

Please sign in to comment.