Filter out all the AuthMethods who don't have a component to render before rendering LogInContainerComponent

This commit is contained in:
Alexandre Vryghem
2023-10-21 18:07:16 +02:00
parent 71cf66ecf4
commit 987a92f529
4 changed files with 18 additions and 35 deletions

View File

@@ -11,11 +11,9 @@ import {
import { hasValue } from '../empty.util';
import { AuthService } from '../../core/auth/auth.service';
import { CoreState } from '../../core/core-state.model';
import { rendersAuthMethodType } from './methods/log-in.methods-decorator';
import { map } from 'rxjs/operators';
/**
* /users/sign-in
* @class LogInComponent
*/
@Component({
selector: 'ds-log-in',
templateUrl: './log-in.component.html',
@@ -57,6 +55,10 @@ export class LogInComponent implements OnInit {
this.authMethods = this.store.pipe(
select(getAuthenticationMethods),
map((methods: AuthMethod[]) => methods
.filter((authMethod: AuthMethod) => rendersAuthMethodType(authMethod.authMethodType) !== undefined)
.sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position)
),
);
// set loading
@@ -73,16 +75,4 @@ export class LogInComponent implements OnInit {
});
}
/**
* Returns an ordered list of {@link AuthMethod}s based on their position.
*
* @param authMethods The {@link AuthMethod}s to sort
*/
getOrderedAuthMethods(authMethods: AuthMethod[] | null): AuthMethod[] {
if (hasValue(authMethods)) {
return [...authMethods].sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position);
} else {
return [];
}
}
}