Skip to content

Commit 1565a1d

Browse files
alisaismailativins01-4science
authored andcommitted
[CST-15073][CST-15074] Fixes
1 parent 83615a1 commit 1565a1d

10 files changed

Lines changed: 31 additions & 14 deletions

File tree

src/app/app.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import {
6363
import { ClientCookieService } from './core/services/client-cookie.service';
6464
import { ListableModule } from './core/shared/listable.module';
6565
import { XsrfInterceptor } from './core/xsrf/xsrf.interceptor';
66+
import { LOGIN_METHOD_FOR_DECORATOR_MAP } from './external-log-in/decorators/external-log-in.methods-decorator';
6667
import { RootModule } from './root.module';
6768
import { AUTH_METHOD_FOR_DECORATOR_MAP } from './shared/log-in/methods/log-in.methods-decorator';
6869
import { METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP } from './shared/metadata-representation/metadata-representation.decorator';
@@ -157,6 +158,7 @@ export const commonAppConfig: ApplicationConfig = {
157158

158159
/* Use models object so all decorators are actually called */
159160
const modelList = models;
161+
const loginMethodForDecoratorMap = LOGIN_METHOD_FOR_DECORATOR_MAP;
160162
const workflowTasks = WORKFLOW_TASK_OPTION_DECORATOR_MAP;
161163
const advancedWorfklowTasks = ADVANCED_WORKFLOW_TASK_OPTION_DECORATOR_MAP;
162164
const metadataRepresentations = METADATA_REPRESENTATION_COMPONENT_DECORATOR_MAP;
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { AuthRegistrationType } from 'src/app/core/auth/models/auth.registration-type';
22

3-
/**
4-
* Map to store the external login confirmation component for the given auth method type
5-
*/
6-
const authMethodsMap = new Map();
3+
import { OrcidConfirmationComponent } from '../registration-types/orcid-confirmation/orcid-confirmation.component';
4+
5+
export type ExternalLoginTypeComponent =
6+
typeof OrcidConfirmationComponent;
7+
8+
export const LOGIN_METHOD_FOR_DECORATOR_MAP = new Map<AuthRegistrationType, ExternalLoginTypeComponent>([
9+
[AuthRegistrationType.Orcid, OrcidConfirmationComponent],
10+
]);
11+
712
/**
813
* Decorator to register the external login confirmation component for the given auth method type
914
* @param authMethodType the type of the external login method
@@ -15,7 +20,7 @@ export function renderExternalLoginConfirmationFor(
1520
if (!objectElement) {
1621
return;
1722
}
18-
authMethodsMap.set(authMethodType, objectElement);
23+
LOGIN_METHOD_FOR_DECORATOR_MAP.set(authMethodType, objectElement);
1924
};
2025
}
2126
/**
@@ -25,5 +30,5 @@ export function renderExternalLoginConfirmationFor(
2530
export function getExternalLoginConfirmationType(
2631
authMethodType: AuthRegistrationType,
2732
) {
28-
return authMethodsMap.get(authMethodType);
33+
return LOGIN_METHOD_FOR_DECORATOR_MAP.get(authMethodType);
2934
}

src/app/external-log-in/external-log-in/external-log-in.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ import {
3030
isEmpty,
3131
} from '../../shared/empty.util';
3232
import { ThemedLogInComponent } from '../../shared/log-in/themed-log-in.component';
33-
import { getExternalLoginConfirmationType } from '../decorators/external-log-in.methods-decorator';
33+
import {
34+
ExternalLoginTypeComponent,
35+
getExternalLoginConfirmationType,
36+
} from '../decorators/external-log-in.methods-decorator';
3437
import { ConfirmEmailComponent } from '../email-confirmation/confirm-email/confirm-email.component';
3538
import { ProvideEmailComponent } from '../email-confirmation/provide-email/provide-email.component';
3639

@@ -151,7 +154,7 @@ export class ExternalLogInComponent implements OnInit, OnDestroy {
151154
/**
152155
* Get the registration type to be rendered
153156
*/
154-
getExternalLoginConfirmationType() {
157+
getExternalLoginConfirmationType(): ExternalLoginTypeComponent {
155158
return getExternalLoginConfirmationType(this.registrationType);
156159
}
157160

src/app/external-log-in/registration-types/orcid-confirmation/orcid-confirmation.component.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import {
1212
} from '@angular/forms';
1313
import { TranslateModule } from '@ngx-translate/core';
1414

15-
import { AuthRegistrationType } from '../../../core/auth/models/auth.registration-type';
1615
import { Registration } from '../../../core/shared/registration.model';
1716
import { BrowserOnlyPipe } from '../../../shared/utils/browser-only.pipe';
18-
import { renderExternalLoginConfirmationFor } from '../../decorators/external-log-in.methods-decorator';
1917
import { ExternalLoginMethodEntryComponent } from '../../decorators/external-login-method-entry.component';
2018

2119
@Component({
@@ -31,7 +29,6 @@ import { ExternalLoginMethodEntryComponent } from '../../decorators/external-log
3129
],
3230
standalone: true,
3331
})
34-
@renderExternalLoginConfirmationFor(AuthRegistrationType.Orcid)
3532
export class OrcidConfirmationComponent extends ExternalLoginMethodEntryComponent implements OnInit {
3633

3734
/**

src/app/external-log-in/services/external-login.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class ExternalLoginService {
6767
return this.store.pipe(
6868
select(getAuthenticationMethods),
6969
filter((methods: AuthMethod[]) => methods.length > 0),
70-
map((methods: AuthMethod[]) => methods.find(m => m.authMethodType === registrationType.toLocaleLowerCase()).location),
70+
map((methods: AuthMethod[]) => methods.find((m: AuthMethod) => m.authMethodType.toString() === registrationType.toLocaleLowerCase()).location),
7171
);
7272
}
7373
}

src/app/shared/log-in/log-in.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
<ds-log-in-container [authMethod]="authMethod" [isStandalonePage]="isStandalonePage"></ds-log-in-container>
55
<div *ngIf="!last" class="dropdown-divider my-2"></div>
66
</ng-container>
7+
<ng-container *ngIf="(authMethods | async).length === 0">
8+
{{ 'login.no-auth-methods' | translate }}
9+
</ng-container>
710
</div>

src/app/shared/log-in/log-in.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
select,
1414
Store,
1515
} from '@ngrx/store';
16+
import { TranslateModule } from '@ngx-translate/core';
1617
import uniqBy from 'lodash/uniqBy';
1718
import { Observable } from 'rxjs';
1819
import { map } from 'rxjs/operators';
@@ -38,7 +39,7 @@ import { rendersAuthMethodType } from './methods/log-in.methods-decorator';
3839
styleUrls: ['./log-in.component.scss'],
3940
changeDetection: ChangeDetectionStrategy.OnPush,
4041
standalone: true,
41-
imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe],
42+
imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe, TranslateModule],
4243
})
4344
export class LogInComponent implements OnInit {
4445

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,6 +3202,8 @@
32023202

32033203
"login.breadcrumbs": "Login",
32043204

3205+
"login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.",
3206+
32053207
"logout.form.header": "Log out from DSpace",
32063208

32073209
"logout.form.submit": "Log out",

src/assets/i18n/it.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4227,6 +4227,9 @@
42274227
// "login.breadcrumbs": "Login",
42284228
"login.breadcrumbs": "Accesso",
42294229

4230+
// "login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.",
4231+
// TODO New key - Add a translation
4232+
"login.no-auth-methods": "No other authentication methods are available for this DSpace instance. Please contact your administrator.",
42304233

42314234

42324235
// "logout.form.header": "Log out from DSpace",

src/themes/custom/app/shared/log-in/log-in.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
NgIf,
55
} from '@angular/common';
66
import { Component } from '@angular/core';
7+
import { TranslateModule } from '@ngx-translate/core';
78
import { ThemedLoadingComponent } from 'src/app/shared/loading/themed-loading.component';
89
import { LogInContainerComponent } from 'src/app/shared/log-in/container/log-in-container.component';
910

@@ -16,7 +17,7 @@ import { LogInComponent as BaseComponent } from '../../../../../app/shared/log-i
1617
// styleUrls: ['./log-in.component.scss'],
1718
styleUrls: ['../../../../../app/shared/log-in/log-in.component.scss'],
1819
standalone: true,
19-
imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe],
20+
imports: [NgIf, ThemedLoadingComponent, NgFor, LogInContainerComponent, AsyncPipe, TranslateModule],
2021
})
2122
export class LogInComponent extends BaseComponent {
2223
}

0 commit comments

Comments
 (0)