From 3dc73f90214bc9fd288aaf0e0a06bc5912aadfbb Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Wed, 2 Aug 2023 21:25:58 +0200 Subject: [PATCH] Properly handle AuthMethod subscription in LogInComponent --- src/app/shared/log-in/log-in.component.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/app/shared/log-in/log-in.component.ts b/src/app/shared/log-in/log-in.component.ts index f47ea2d77e..4bfae18332 100644 --- a/src/app/shared/log-in/log-in.component.ts +++ b/src/app/shared/log-in/log-in.component.ts @@ -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 { @@ -35,7 +35,7 @@ export class LogInComponent implements OnInit { * The list of authentication methods available * @type {AuthMethod[]} */ - public authMethods: AuthMethod[]; + public authMethods: Observable; /** * Whether user is authenticated. @@ -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));