diff --git a/src/app/shared/log-in/container/log-in-container.component.ts b/src/app/shared/log-in/container/log-in-container.component.ts index f6a08a1e1ec..28e9f2f7e18 100644 --- a/src/app/shared/log-in/container/log-in-container.component.ts +++ b/src/app/shared/log-in/container/log-in-container.component.ts @@ -1,5 +1,4 @@ -import { Component, Injector, Input, OnInit } from '@angular/core'; - +import { Component, Injector, Input, OnInit, Type } from '@angular/core'; import { rendersAuthMethodType } from '../methods/log-in.methods-decorator'; import { AuthMethod } from '../../../core/auth/models/auth.method'; @@ -27,12 +26,9 @@ export class LogInContainerComponent implements OnInit { */ public objectInjector: Injector; - /** - * Initialize instance variables - * - * @param {Injector} injector - */ - constructor(private injector: Injector) { + constructor( + protected injector: Injector, + ) { } /** @@ -51,8 +47,8 @@ export class LogInContainerComponent implements OnInit { /** * Find the correct component based on the AuthMethod's type */ - getAuthMethodContent(): string { - return rendersAuthMethodType(this.authMethod.authMethodType); + getAuthMethodContent(): Type { + return rendersAuthMethodType(this.authMethod.authMethodType); } } diff --git a/src/app/shared/log-in/log-in.component.html b/src/app/shared/log-in/log-in.component.html index 173e0f8e303..2b9fb2e0d43 100644 --- a/src/app/shared/log-in/log-in.component.html +++ b/src/app/shared/log-in/log-in.component.html @@ -1,11 +1,7 @@
- -
-
- -
- -
+ + +
diff --git a/src/app/shared/log-in/log-in.component.ts b/src/app/shared/log-in/log-in.component.ts index 9cc466dcfe2..9d596a2a154 100644 --- a/src/app/shared/log-in/log-in.component.ts +++ b/src/app/shared/log-in/log-in.component.ts @@ -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 []; - } - } } diff --git a/src/app/shared/log-in/methods/log-in.methods-decorator.ts b/src/app/shared/log-in/methods/log-in.methods-decorator.ts index 0614bdeb511..e30a4813dd8 100644 --- a/src/app/shared/log-in/methods/log-in.methods-decorator.ts +++ b/src/app/shared/log-in/methods/log-in.methods-decorator.ts @@ -1,6 +1,7 @@ +import { Component, Type } from '@angular/core'; import { AuthMethodType } from '../../../core/auth/models/auth.method-type'; -const authMethodsMap = new Map(); +const authMethodsMap: Map> = new Map(); export function renderAuthMethodFor(authMethodType: AuthMethodType) { return function decorator(objectElement: any) { @@ -11,6 +12,6 @@ export function renderAuthMethodFor(authMethodType: AuthMethodType) { }; } -export function rendersAuthMethodType(authMethodType: AuthMethodType) { +export function rendersAuthMethodType(authMethodType: AuthMethodType): Type | undefined { return authMethodsMap.get(authMethodType); }