[CST-15074][#3355] PR review

This commit is contained in:
Vincenzo Mecca
2025-03-07 19:51:41 +01:00
parent c2701c412c
commit 77b027a6c6
12 changed files with 130 additions and 174 deletions

View File

@@ -1,46 +1,18 @@
import { NgIf } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Inject,
Input,
OnDestroy,
OnInit,
} from '@angular/core';
import {
FormBuilder,
FormGroup,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
import { ChangeDetectionStrategy, Component, Inject, Input, OnDestroy, OnInit, } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators, } from '@angular/forms';
import { TranslateModule, TranslateService, } from '@ngx-translate/core';
import isEqual from 'lodash/isEqual';
import {
combineLatest,
Subscription,
take,
} from 'rxjs';
import { combineLatest, Subscription, take, } from 'rxjs';
import { AuthService } from '../../../core/auth/auth.service';
import { EPersonDataService } from '../../../core/eperson/eperson-data.service';
import { EPerson } from '../../../core/eperson/models/eperson.model';
import { HardRedirectService } from '../../../core/services/hard-redirect.service';
import {
NativeWindowRef,
NativeWindowService,
} from '../../../core/services/window.service';
import {
getFirstCompletedRemoteData,
getRemoteDataPayload,
} from '../../../core/shared/operators';
import { NativeWindowRef, NativeWindowService, } from '../../../core/services/window.service';
import { getFirstCompletedRemoteData, getRemoteDataPayload, } from '../../../core/shared/operators';
import { Registration } from '../../../core/shared/registration.model';
import {
hasNoValue,
hasValue,
} from '../../../shared/empty.util';
import { hasNoValue, hasValue, } from '../../../shared/empty.util';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { ExternalLoginService } from '../../services/external-login.service';
@@ -56,6 +28,9 @@ import { ExternalLoginService } from '../../services/external-login.service';
ReactiveFormsModule,
],
})
/**
* Email confirmation component that will check for user email confirmation after account creation.
*/
export class ConfirmEmailComponent implements OnInit, OnDestroy {
/**
* The form containing the email input

View File

@@ -1,7 +1,4 @@
import {
ChangeDetectionStrategy,
Component,
} from '@angular/core';
import { ChangeDetectionStrategy, Component, } from '@angular/core';
import { TranslateModule } from '@ngx-translate/core';
@Component({
@@ -13,4 +10,7 @@ import { TranslateModule } from '@ngx-translate/core';
standalone: true,
})
/**
* Simple component that shows up a confirmation to the user.
*/
export class ConfirmationSentComponent { }

View File

@@ -8,7 +8,6 @@
type="email"
id="email"
formControlName="email"
placeholder="Input box"
class="form-control form-control-lg position-relative"
/>

View File

@@ -1,14 +1,8 @@
import { CommonModule } from '@angular/common';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { ComponentFixture, TestBed, } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import {
TranslateLoader,
TranslateModule,
} from '@ngx-translate/core';
import { TranslateLoader, TranslateModule, } from '@ngx-translate/core';
import { TranslateLoaderMock } from '../../../shared/mocks/translate-loader.mock';
import { ExternalLoginService } from '../../services/external-login.service';
@@ -53,16 +47,16 @@ describe('ProvideEmailComponent', () => {
expect(component).toBeTruthy();
});
// it('should call externalLoginService.patchUpdateRegistration when form is submitted with valid email', () => {
// const email = 'test@example.com';
// component.emailForm.setValue({ email });
// component.registrationId = '123';
// component.token = '456';
// fixture.detectChanges();
it('should call externalLoginService.patchUpdateRegistration when form is submitted with valid email', () => {
const email = 'test@example.com';
component.emailForm.setValue({ email });
component.registrationId = '123';
component.token = '456';
fixture.detectChanges();
// const button = fixture.nativeElement.querySelector('button[type="submit"]');
// button.click();
const button = fixture.nativeElement.querySelector('button[type="submit"]');
button.click();
// expect(externalLoginServiceSpy.patchUpdateRegistration).toHaveBeenCalledWith([email], 'email', component.registrationId, component.token, 'add');
// });
expect(externalLoginServiceSpy.patchUpdateRegistration).toHaveBeenCalledWith([email], 'email', component.registrationId, component.token, 'add');
});
});

View File

@@ -1,16 +1,6 @@
import { NgIf } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Input,
OnDestroy,
} from '@angular/core';
import {
FormBuilder,
FormGroup,
ReactiveFormsModule,
Validators,
} from '@angular/forms';
import { ChangeDetectionStrategy, Component, Input, OnDestroy, } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators, } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { Subscription } from 'rxjs';
@@ -29,6 +19,9 @@ import { ExternalLoginService } from '../../services/external-login.service';
],
standalone: true,
})
/**
* This component provides a proper field to submit the email that will be updated for its registration token
*/
export class ProvideEmailComponent implements OnDestroy {
/**
* The form group for the email input

View File

@@ -1,23 +1,7 @@
import {
NgComponentOutlet,
NgIf,
} from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Injector,
Input,
OnDestroy,
OnInit,
} from '@angular/core';
import {
NgbModal,
NgbModalRef,
} from '@ng-bootstrap/ng-bootstrap';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
import { NgComponentOutlet, NgIf, } from '@angular/common';
import { ChangeDetectionStrategy, Component, Injector, Input, OnDestroy, OnInit, } from '@angular/core';
import { NgbModal, NgbModalRef, } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule, TranslateService, } from '@ngx-translate/core';
import { AuthService } from '../../core/auth/auth.service';
import { AuthMethodType } from '../../core/auth/models/auth.method-type';
@@ -25,10 +9,7 @@ import { AuthRegistrationType } from '../../core/auth/models/auth.registration-t
import { Registration } from '../../core/shared/registration.model';
import { AlertComponent } from '../../shared/alert/alert.component';
import { AlertType } from '../../shared/alert/alert-type';
import {
hasValue,
isEmpty,
} from '../../shared/empty.util';
import { hasValue, isEmpty, } from '../../shared/empty.util';
import { ThemedLogInComponent } from '../../shared/log-in/themed-log-in.component';
import {
ExternalLoginTypeComponent,
@@ -53,6 +34,9 @@ import { ProvideEmailComponent } from '../email-confirmation/provide-email/provi
],
standalone: true,
})
/**
* This component is responsible to handle the external-login depending on the RegistrationData details provided
*/
export class ExternalLogInComponent implements OnInit, OnDestroy {
/**
* The AlertType enumeration for access in the component's template

View File

@@ -1,15 +1,6 @@
import { NgIf } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Inject,
OnInit,
} from '@angular/core';
import {
FormBuilder,
FormGroup,
ReactiveFormsModule,
} from '@angular/forms';
import { ChangeDetectionStrategy, Component, Inject, OnInit, } from '@angular/core';
import { FormBuilder, FormGroup, ReactiveFormsModule, } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { Registration } from '../../../core/shared/registration.model';
@@ -29,6 +20,9 @@ import { ExternalLoginMethodEntryComponent } from '../../decorators/external-log
],
standalone: true,
})
/**
* This component is responsible to show the registered data inside the registration token to the user
*/
export class OrcidConfirmationComponent extends ExternalLoginMethodEntryComponent implements OnInit {
/**

View File

@@ -1,15 +1,8 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import {
select,
Store,
} from '@ngrx/store';
import { select, Store, } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import {
filter,
map,
Observable,
} from 'rxjs';
import { filter, map, Observable, } from 'rxjs';
import { AuthMethod } from 'src/app/core/auth/models/auth.method';
import { getAuthenticationMethods } from 'src/app/core/auth/selectors';
import { CoreState } from 'src/app/core/core-state.model';
@@ -23,6 +16,10 @@ import { NotificationsService } from '../../shared/notifications/notifications.s
@Injectable({
providedIn: 'root',
})
/**
* This service is responsible to communicate with the epersonRegistrationService to update the RegistrationData
* provided by the user.
*/
export class ExternalLoginService {
constructor(

View File

@@ -1,19 +1,8 @@
import {
AsyncPipe,
NgIf,
} from '@angular/common';
import {
Component,
OnInit,
} from '@angular/core';
import { AsyncPipe, NgIf, } from '@angular/common';
import { Component, OnInit, } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import {
first,
map,
Observable,
tap,
} from 'rxjs';
import { first, map, Observable, tap, } from 'rxjs';
import { RemoteData } from '../core/data/remote-data';
import { Registration } from '../core/shared/registration.model';
@@ -34,6 +23,9 @@ import { hasNoValue } from '../shared/empty.util';
],
standalone: true,
})
/**
* This component is a wrapper of the external-login component that loads up the RegistrationData.
*/
export class ExternalLoginPageComponent implements OnInit {
/**
* The token used to get the registration data,

View File

@@ -1,18 +1,7 @@
import {
AsyncPipe,
NgIf,
} from '@angular/common';
import {
Component,
OnInit,
} from '@angular/core';
import { AsyncPipe, NgIf, } from '@angular/common';
import { Component, OnInit, } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {
first,
map,
Observable,
tap,
} from 'rxjs';
import { first, map, Observable, tap, } from 'rxjs';
import { RemoteData } from '../core/data/remote-data';
import { Registration } from '../core/shared/registration.model';
@@ -32,6 +21,9 @@ import { ReviewAccountInfoComponent } from './review-account-info/review-account
],
standalone: true,
})
/**
* This component is a wrapper for review-account-info component responsible to provide RegistrationData.
*/
export class ExternalLoginReviewAccountInfoPageComponent implements OnInit {
/**
* The token used to get the registration data

View File

@@ -1,34 +1,10 @@
import {
NgFor,
NgIf,
TitleCasePipe,
} from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Inject,
Input,
OnDestroy,
OnInit,
} from '@angular/core';
import { NgFor, NgIf, TitleCasePipe, } from '@angular/common';
import { ChangeDetectionStrategy, Component, Inject, Input, OnDestroy, OnInit, } from '@angular/core';
import { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import {
TranslateModule,
TranslateService,
} from '@ngx-translate/core';
import { TranslateModule, TranslateService, } from '@ngx-translate/core';
import { UiSwitchModule } from 'ngx-ui-switch';
import {
combineLatest,
filter,
from,
map,
Observable,
Subscription,
switchMap,
take,
tap,
} from 'rxjs';
import { combineLatest, filter, from, map, Observable, Subscription, switchMap, take, tap, } from 'rxjs';
import { AuthService } from '../../core/auth/auth.service';
import { AuthRegistrationType } from '../../core/auth/models/auth.registration-type';
@@ -36,10 +12,7 @@ import { RemoteData } from '../../core/data/remote-data';
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
import { EPerson } from '../../core/eperson/models/eperson.model';
import { HardRedirectService } from '../../core/services/hard-redirect.service';
import {
NativeWindowRef,
NativeWindowService,
} from '../../core/services/window.service';
import { NativeWindowRef, NativeWindowService, } from '../../core/services/window.service';
import { Registration } from '../../core/shared/registration.model';
import { ExternalLoginService } from '../../external-log-in/services/external-login.service';
import { AlertComponent } from '../../shared/alert/alert.component';
@@ -73,6 +46,10 @@ export interface ReviewAccountInfoData {
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
/**
* This component shows up the difference between the current account details and the one provided by the
* Registration data.
*/
export class ReviewAccountInfoComponent implements OnInit, OnDestroy {
/**
* The AlertType enumeration for access in the component's template

View File

@@ -6795,4 +6795,63 @@
"live-region.ordering.dropped": "{{ itemName }}, dropped at position {{ index }} of {{ length }}.",
"dynamic-form-array.sortable-list.label": "Sortable list",
"external-login.confirmation.header": "Information needed to complete the login process",
"external-login.noEmail.informationText": "The information received from {{authMethod}} are not sufficient to complete the login process. Please provide the missing information below, or login via a different method to associate your {{authMethod}} to an existing account.",
"external-login.haveEmail.informationText": "It seems that you have not yet an account in this system. If this is the case, please confirm the data received from {{authMethod}} and a new account will be created for you. Otherwise, if you already have an account in the system, please update the email address to match the one already in use in the system or login via a different method to associate your {{authMethod}} to your existing account.",
"external-login.confirm-email.header": "Confirm or update email",
"external-login.confirmation.email-required": "Email is required.",
"external-login.confirmation.email-invalid": "Invalid email format.",
"external-login.confirm.button.label": "Confirm this email",
"external-login.confirm-email-sent.header": "Confirmation email sent",
"external-login.confirm-email-sent.info": " We have sent an emait to the provided address to validate your input. <br> Please follow the instructions in the email to complete the login process.",
"external-login.provide-email.header": "Provide email",
"external-login.provide-email.button.label": "Send Verification link",
"external-login-validation.review-account-info.header": "Review your account information",
"external-login-validation.review-account-info.info": "The information received from ORCID differs from the one recorded in your profile. <br /> Please review them and decide if you want to update any of them.After saving you will be redirected to your profile page.",
"external-login-validation.review-account-info.table.header.information": "Information",
"external-login-validation.review-account-info.table.header.received-value": "Received value",
"external-login-validation.review-account-info.table.header.current-value": "Current value",
"external-login-validation.review-account-info.table.header.action": "Override",
"on-label": "ON",
"off-label": "OFF",
"review-account-info.merge-data.notification.success": "Your account information has been updated successfully",
"review-account-info.merge-data.notification.error": "Something went wrong while updating your account information",
"review-account-info.alert.error.content": "Something went wrong. Please try again later.",
"external-login-page.provide-email.notifications.error": "Something went wrong.Email address was omitted or the operation is not valid.",
"external-login.error.notification": "There was an error while processing your request. Please try again later.",
"external-login.connect-to-existing-account.label": "Connect to an existing user",
"external-login.modal.label.close": "Close",
"external-login-page.provide-email.create-account.notifications.error.header": "Something went wrong",
"external-login-page.provide-email.create-account.notifications.error.content": "Please check again your email address and try again.",
"external-login-page.confirm-email.create-account.notifications.error.no-netId": "Something went wrong with this email account. Try again or use a different method to login."
}