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..1bdde5c9f11 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 @@ -2,6 +2,7 @@ import { Component, Injector, Input, OnInit } from '@angular/core'; import { rendersAuthMethodType } from '../methods/log-in.methods-decorator'; import { AuthMethod } from '../../../core/auth/models/auth.method'; +import { ThemeService } from '../../theme-support/theme.service'; /** * This component represents a component container for log-in methods available. @@ -27,12 +28,10 @@ export class LogInContainerComponent implements OnInit { */ public objectInjector: Injector; - /** - * Initialize instance variables - * - * @param {Injector} injector - */ - constructor(private injector: Injector) { + constructor( + private injector: Injector, + private themeService: ThemeService, + ) { } /** @@ -52,7 +51,7 @@ export class LogInContainerComponent implements OnInit { * Find the correct component based on the AuthMethod's type */ getAuthMethodContent(): string { - return rendersAuthMethodType(this.authMethod.authMethodType); + return rendersAuthMethodType(this.authMethod.authMethodType, this.themeService.getThemeName()); } } 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..84e1ea77b61 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,16 +1,21 @@ import { AuthMethodType } from '../../../core/auth/models/auth.method-type'; +import { DEFAULT_THEME } from '../../object-collection/shared/listable-object/listable-object.decorator'; +import { hasNoValue } from '../../empty.util'; +import { getMatch } from '../../abstract-component-loader/dynamic-component-loader.utils'; + +export const DEFAULT_AUTH_METHOD_TYPE = AuthMethodType.Password; const authMethodsMap = new Map(); -export function renderAuthMethodFor(authMethodType: AuthMethodType) { - return function decorator(objectElement: any) { - if (!objectElement) { - return; +export function renderAuthMethodFor(authMethodType: AuthMethodType, theme = DEFAULT_THEME) { + return function decorator(component: any) { + if (hasNoValue(authMethodsMap.get(authMethodType))) { + authMethodsMap.set(authMethodType, new Map()); } - authMethodsMap.set(authMethodType, objectElement); + authMethodsMap.get(authMethodType).set(theme, component); }; } -export function rendersAuthMethodType(authMethodType: AuthMethodType) { - return authMethodsMap.get(authMethodType); +export function rendersAuthMethodType(authMethodType: AuthMethodType, theme: string) { + return getMatch(authMethodsMap, [authMethodType, theme], [DEFAULT_AUTH_METHOD_TYPE, DEFAULT_THEME]).match; }