diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 61a04c8adb..41f934d2bf 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -63,6 +63,7 @@ import { import { ClientCookieService } from './core/services/client-cookie.service'; import { ListableModule } from './core/shared/listable.module'; import { XsrfInterceptor } from './core/xsrf/xsrf.interceptor'; +import { LOGIN_METHOD_FOR_DECORATOR_MAP } from './external-log-in/decorators/external-log-in.methods-decorator'; import { RootModule } from './root.module'; import { AUTH_METHOD_FOR_DECORATOR_MAP } from './shared/log-in/methods/log-in.methods-decorator'; import { METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP } from './shared/metadata-representation/metadata-representation.decorator'; @@ -157,6 +158,7 @@ export const commonAppConfig: ApplicationConfig = { /* Use models object so all decorators are actually called */ const modelList = models; +const loginMethodForDecoratorMap = LOGIN_METHOD_FOR_DECORATOR_MAP; const workflowTasks = WORKFLOW_TASK_OPTION_DECORATOR_MAP; const advancedWorfklowTasks = ADVANCED_WORKFLOW_TASK_OPTION_DECORATOR_MAP; const metadataRepresentations = METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP; diff --git a/src/app/external-log-in/decorators/external-log-in.methods-decorator.ts b/src/app/external-log-in/decorators/external-log-in.methods-decorator.ts index 0144924776..593dbb3aea 100644 --- a/src/app/external-log-in/decorators/external-log-in.methods-decorator.ts +++ b/src/app/external-log-in/decorators/external-log-in.methods-decorator.ts @@ -1,9 +1,14 @@ import { AuthRegistrationType } from 'src/app/core/auth/models/auth.registration-type'; -/** - * Map to store the external login confirmation component for the given auth method type - */ -const authMethodsMap = new Map(); +import { OrcidConfirmationComponent } from '../registration-types/orcid-confirmation/orcid-confirmation.component'; + +export type ExternalLoginTypeComponent = + typeof OrcidConfirmationComponent; + +export const LOGIN_METHOD_FOR_DECORATOR_MAP = new Map([ + [AuthRegistrationType.Orcid, OrcidConfirmationComponent], +]); + /** * Decorator to register the external login confirmation component for the given auth method type * @param authMethodType the type of the external login method @@ -15,7 +20,7 @@ export function renderExternalLoginConfirmationFor( if (!objectElement) { return; } - authMethodsMap.set(authMethodType, objectElement); + LOGIN_METHOD_FOR_DECORATOR_MAP.set(authMethodType, objectElement); }; } /** @@ -25,5 +30,5 @@ export function renderExternalLoginConfirmationFor( export function getExternalLoginConfirmationType( authMethodType: AuthRegistrationType, ) { - return authMethodsMap.get(authMethodType); + return LOGIN_METHOD_FOR_DECORATOR_MAP.get(authMethodType); } diff --git a/src/app/external-log-in/external-log-in/external-log-in.component.ts b/src/app/external-log-in/external-log-in/external-log-in.component.ts index a89fbb7564..25bac19d85 100644 --- a/src/app/external-log-in/external-log-in/external-log-in.component.ts +++ b/src/app/external-log-in/external-log-in/external-log-in.component.ts @@ -30,7 +30,10 @@ import { isEmpty, } from '../../shared/empty.util'; import { ThemedLogInComponent } from '../../shared/log-in/themed-log-in.component'; -import { getExternalLoginConfirmationType } from '../decorators/external-log-in.methods-decorator'; +import { + ExternalLoginTypeComponent, + getExternalLoginConfirmationType, +} from '../decorators/external-log-in.methods-decorator'; import { ConfirmEmailComponent } from '../email-confirmation/confirm-email/confirm-email.component'; import { ProvideEmailComponent } from '../email-confirmation/provide-email/provide-email.component'; @@ -151,7 +154,7 @@ export class ExternalLogInComponent implements OnInit, OnDestroy { /** * Get the registration type to be rendered */ - getExternalLoginConfirmationType() { + getExternalLoginConfirmationType(): ExternalLoginTypeComponent { return getExternalLoginConfirmationType(this.registrationType); } diff --git a/src/app/external-log-in/registration-types/orcid-confirmation/orcid-confirmation.component.ts b/src/app/external-log-in/registration-types/orcid-confirmation/orcid-confirmation.component.ts index 7b7097b59c..909f17c2df 100644 --- a/src/app/external-log-in/registration-types/orcid-confirmation/orcid-confirmation.component.ts +++ b/src/app/external-log-in/registration-types/orcid-confirmation/orcid-confirmation.component.ts @@ -12,10 +12,8 @@ import { } from '@angular/forms'; import { TranslateModule } from '@ngx-translate/core'; -import { AuthRegistrationType } from '../../../core/auth/models/auth.registration-type'; import { Registration } from '../../../core/shared/registration.model'; import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe'; -import { renderExternalLoginConfirmationFor } from '../../decorators/external-log-in.methods-decorator'; import { ExternalLoginMethodEntryComponent } from '../../decorators/external-login-method-entry.component'; @Component({ @@ -31,7 +29,6 @@ import { ExternalLoginMethodEntryComponent } from '../../decorators/external-log ], standalone: true, }) -@renderExternalLoginConfirmationFor(AuthRegistrationType.Orcid) export class OrcidConfirmationComponent extends ExternalLoginMethodEntryComponent implements OnInit { /** diff --git a/src/app/external-log-in/services/external-login.service.ts b/src/app/external-log-in/services/external-login.service.ts index 320914388d..fb9f9fd66f 100644 --- a/src/app/external-log-in/services/external-login.service.ts +++ b/src/app/external-log-in/services/external-login.service.ts @@ -67,7 +67,7 @@ export class ExternalLoginService { return this.store.pipe( select(getAuthenticationMethods), filter((methods: AuthMethod[]) => methods.length > 0), - map((methods: AuthMethod[]) => methods.find(m => m.authMethodType === registrationType.toLocaleLowerCase()).location), + map((methods: AuthMethod[]) => methods.find((m: AuthMethod) => m.authMethodType.toString() === registrationType.toLocaleLowerCase()).location), ); } } diff --git a/src/app/shared/log-in/log-in.component.html b/src/app/shared/log-in/log-in.component.html index 309e226772..c90cf5a683 100644 --- a/src/app/shared/log-in/log-in.component.html +++ b/src/app/shared/log-in/log-in.component.html @@ -4,4 +4,7 @@ + + {{ 'login.no-auth-methods' | translate }} + diff --git a/src/app/shared/log-in/log-in.component.ts b/src/app/shared/log-in/log-in.component.ts index 75fead1fda..2f7ee1abc5 100644 --- a/src/app/shared/log-in/log-in.component.ts +++ b/src/app/shared/log-in/log-in.component.ts @@ -13,6 +13,7 @@ import { select, Store, } from '@ngrx/store'; +import { TranslateModule } from '@ngx-translate/core'; import uniqBy from 'lodash/uniqBy'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @@ -38,7 +39,7 @@ import { rendersAuthMethodType } from './methods/log-in.methods-decorator'; styleUrls: ['./log-in.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, standalone: true, - imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe], + imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe, TranslateModule], }) export class LogInComponent implements OnInit { diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 47c97b8782..b04af0df3e 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3202,6 +3202,8 @@ "login.breadcrumbs": "Login", + "login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.", + "logout.form.header": "Log out from DSpace", "logout.form.submit": "Log out", diff --git a/src/assets/i18n/it.json5 b/src/assets/i18n/it.json5 index f68394e7dd..75119cc89b 100644 --- a/src/assets/i18n/it.json5 +++ b/src/assets/i18n/it.json5 @@ -4227,6 +4227,9 @@ // "login.breadcrumbs": "Login", "login.breadcrumbs": "Accesso", + // "login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.", + // TODO New key - Add a translation + "login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.", // "logout.form.header": "Log out from DSpace", diff --git a/src/themes/custom/app/shared/log-in/log-in.component.ts b/src/themes/custom/app/shared/log-in/log-in.component.ts index 1af5505835..63388d01a3 100644 --- a/src/themes/custom/app/shared/log-in/log-in.component.ts +++ b/src/themes/custom/app/shared/log-in/log-in.component.ts @@ -4,6 +4,7 @@ import { NgIf, } from '@angular/common'; import { Component } from '@angular/core'; +import { TranslateModule } from '@ngx-translate/core'; import { ThemedLoadingComponent } from 'src/app/shared/loading/themed-loading.component'; import { LogInContainerComponent } from 'src/app/shared/log-in/container/log-in-container.component'; @@ -16,7 +17,7 @@ import { LogInComponent as BaseComponent } from '../../../../../app/shared/log-i // styleUrls: ['./log-in.component.scss'], styleUrls: ['../../../../../app/shared/log-in/log-in.component.scss'], standalone: true, - imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe], + imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe, TranslateModule], }) export class LogInComponent extends BaseComponent { }