Merge branch 'fix-display-order-authentication-methods_contribute-7.4' into fix-display-order-authentication-methods_contribute-7.6

# Conflicts:
#	src/app/shared/log-in/log-in.component.html
#	src/app/shared/log-in/log-in.component.ts
This commit is contained in:
Alexandre Vryghem
2023-10-21 18:09:59 +02:00
6 changed files with 20 additions and 41 deletions

View File

@@ -11,12 +11,8 @@ import {
import { hasValue } from '../empty.util';
import { AuthService } from '../../core/auth/auth.service';
import { CoreState } from '../../core/core-state.model';
import { AuthMethodType } from '../../core/auth/models/auth.method-type';
import { rendersAuthMethodType } from './methods/log-in.methods-decorator';
/**
* /users/sign-in
* @class LogInComponent
*/
@Component({
selector: 'ds-log-in',
templateUrl: './log-in.component.html',
@@ -57,8 +53,10 @@ export class LogInComponent implements OnInit {
ngOnInit(): void {
this.authMethods = this.store.pipe(
select(getAuthenticationMethods),
// ignore the ip authentication method when it's returned by the backend
map((methods: AuthMethod[]) => methods.filter((authMethod: AuthMethod) => authMethod.authMethodType !== AuthMethodType.Ip)),
map((methods: AuthMethod[]) => methods
.filter((authMethod: AuthMethod) => rendersAuthMethodType(authMethod.authMethodType) !== undefined)
.sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position)
),
);
// set loading
@@ -75,16 +73,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 [];
}
}
}