[DURACOM-191] remove provide-render-auth-method, use exported const instead

This commit is contained in:
Andrea Barbasso
2024-01-18 15:53:31 +01:00
parent e287e25906
commit bb64be3a2b
3 changed files with 15 additions and 25 deletions

View File

@@ -33,10 +33,10 @@ import { ThemedRootComponent } from './root/themed-root.component';
import { workflowTasks } from './core/provide-workflow-tasks'; import { workflowTasks } from './core/provide-workflow-tasks';
import { metadataRepresentations } from './core/provide-metadata-representation'; import { metadataRepresentations } from './core/provide-metadata-representation';
import { renderStartsWith } from './core/provide-render-starts-with'; import { renderStartsWith } from './core/provide-render-starts-with';
import { renderAuthMethod } from './core/provide-render-auth-method';
import { NgxMaskModule } from 'ngx-mask'; import { NgxMaskModule } from 'ngx-mask';
import { ListableModule } from './core/shared/listable.module'; import { ListableModule } from './core/shared/listable.module';
import { BROWSE_BY_DECORATOR_MAP } from './browse-by/browse-by-switcher/browse-by-decorator'; import { BROWSE_BY_DECORATOR_MAP } from './browse-by/browse-by-switcher/browse-by-decorator';
import { AUTH_METHOD_FOR_DECORATOR_MAP } from './shared/log-in/methods/log-in.methods-decorator';
export function getConfig() { export function getConfig() {
return environment; return environment;
@@ -138,5 +138,5 @@ export class AppModule {
metadataRepresentations = metadataRepresentations; metadataRepresentations = metadataRepresentations;
renderStartsWith = renderStartsWith; renderStartsWith = renderStartsWith;
browseByDecoratorMap = BROWSE_BY_DECORATOR_MAP; browseByDecoratorMap = BROWSE_BY_DECORATOR_MAP;
renderAuthMethod = renderAuthMethod; authMethodForDecoratorMap = AUTH_METHOD_FOR_DECORATOR_MAP;
} }

View File

@@ -1,14 +0,0 @@
import {
LogInExternalProviderComponent
} from '../shared/log-in/methods/log-in-external-provider/log-in-external-provider.component';
import { LogInPasswordComponent } from '../shared/log-in/methods/password/log-in-password.component';
/**
* Declaration needed to make sure all decorator functions are called in time
*/
export const renderAuthMethod =
[
LogInExternalProviderComponent,
LogInPasswordComponent,
];

View File

@@ -1,23 +1,27 @@
import { Component, Type } from '@angular/core';
import { AuthMethodType } from '../../../core/auth/models/auth.method-type'; import { AuthMethodType } from '../../../core/auth/models/auth.method-type';
import { LogInPasswordComponent } from './password/log-in-password.component'; import { LogInPasswordComponent } from './password/log-in-password.component';
import { LogInExternalProviderComponent } from './log-in-external-provider/log-in-external-provider.component'; import { LogInExternalProviderComponent } from './log-in-external-provider/log-in-external-provider.component';
const authMethodsMap: Map<AuthMethodType, any> = new Map(); type AuthMethodTypeComponent =
typeof LogInPasswordComponent |
typeof LogInExternalProviderComponent;
export const AUTH_METHOD_FOR_DECORATOR_MAP = new Map<AuthMethodType, AuthMethodTypeComponent>([
[AuthMethodType.Password, LogInPasswordComponent],
[AuthMethodType.Shibboleth, LogInExternalProviderComponent],
[AuthMethodType.Oidc, LogInExternalProviderComponent],
[AuthMethodType.Orcid, LogInExternalProviderComponent]
]);
authMethodsMap.set(AuthMethodType.Password, LogInPasswordComponent);
authMethodsMap.set(AuthMethodType.Shibboleth, LogInExternalProviderComponent);
authMethodsMap.set(AuthMethodType.Oidc, LogInExternalProviderComponent);
authMethodsMap.set(AuthMethodType.Orcid, LogInExternalProviderComponent);
export function renderAuthMethodFor(authMethodType: AuthMethodType) { export function renderAuthMethodFor(authMethodType: AuthMethodType) {
return function decorator(objectElement: any) { return function decorator(objectElement: any) {
if (!objectElement) { if (!objectElement) {
return; return;
} }
authMethodsMap.set(authMethodType, objectElement); AUTH_METHOD_FOR_DECORATOR_MAP.set(authMethodType, objectElement);
}; };
} }
export function rendersAuthMethodType(authMethodType: AuthMethodType): Type<Component> | undefined { export function rendersAuthMethodType(authMethodType: AuthMethodType) {
return authMethodsMap.get(authMethodType); return AUTH_METHOD_FOR_DECORATOR_MAP.get(authMethodType);
} }