[CST-15074][#3355] PR review

This commit is contained in:
Vincenzo Mecca
2025-03-12 20:15:57 +01:00
parent f2c5912dfa
commit d6776a8a1e
9 changed files with 155 additions and 117 deletions

View File

@@ -9,16 +9,13 @@ import {
select,
Store,
} from '@ngrx/store';
import uniqBy from 'lodash/uniqBy';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { AuthService } from '../../core/auth/auth.service';
import { AuthMethod } from '../../core/auth/models/auth.method';
import { AuthMethodType } from '../../core/auth/models/auth.method-type';
import {
getAuthenticationError,
getAuthenticationMethods,
isAuthenticated,
isAuthenticationLoading,
} from '../../core/auth/selectors';
@@ -26,7 +23,6 @@ import { CoreState } from '../../core/core-state.model';
import { hasValue } from '../empty.util';
import { ThemedLoadingComponent } from '../loading/themed-loading.component';
import { LogInContainerComponent } from './container/log-in-container.component';
import { rendersAuthMethodType } from './methods/log-in.methods-decorator';
@Component({
selector: 'ds-base-log-in',
@@ -77,17 +73,7 @@ export class LogInComponent implements OnInit {
}
ngOnInit(): void {
this.authMethods = this.store.pipe(
select(getAuthenticationMethods),
map((methods: AuthMethod[]) => methods
// ignore the given auth method if it should be excluded
.filter((authMethod: AuthMethod) => authMethod.authMethodType !== this.excludedAuthMethod)
.filter((authMethod: AuthMethod) => rendersAuthMethodType(authMethod.authMethodType) !== undefined)
.sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position),
),
// ignore the ip authentication method when it's returned by the backend
map((authMethods: AuthMethod[]) => uniqBy(authMethods.filter(a => a.authMethodType !== AuthMethodType.Ip), 'authMethodType')),
);
this.authMethods = this.authService.getAuthMethods(this.excludedAuthMethod);
// set loading
this.loading = this.store.pipe(select(isAuthenticationLoading));