diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html
index 5d80f24990..41ae67423c 100644
--- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html
+++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html
@@ -19,7 +19,7 @@
class="btn btn-outline-secondary"> {{messagePrefix + '.return' | translate}}
-
@@ -42,7 +42,7 @@
{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}
-
+
0"
[paginationOptions]="config"
diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts
index 1f4a106bfa..5593c77523 100644
--- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts
+++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.spec.ts
@@ -28,8 +28,9 @@ import { createPaginatedList } from '../../../shared/testing/utils.test';
import { RequestService } from '../../../core/data/request.service';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
-import { FormArray, FormControl, FormGroup,Validators, NG_VALIDATORS, NG_ASYNC_VALIDATORS } from '@angular/forms';
+import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ValidateEmailNotTaken } from './validators/email-taken.validator';
+import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service';
describe('EPersonFormComponent', () => {
@@ -42,6 +43,7 @@ describe('EPersonFormComponent', () => {
let authService: AuthServiceStub;
let authorizationService: AuthorizationDataService;
let groupsDataService: GroupDataService;
+ let epersonRegistrationService: EpersonRegistrationService;
let paginationService;
@@ -205,6 +207,10 @@ describe('EPersonFormComponent', () => {
}).compileComponents();
}));
+ epersonRegistrationService = jasmine.createSpyObj('epersonRegistrationService', {
+ registerEmail: createSuccessfulRemoteDataObject$(null)
+ });
+
beforeEach(() => {
fixture = TestBed.createComponent(EPersonFormComponent);
component = fixture.componentInstance;
@@ -514,4 +520,24 @@ describe('EPersonFormComponent', () => {
expect(component.epersonService.deleteEPerson).toHaveBeenCalledWith(eperson);
});
});
+
+
+ describe('Reset Password', () => {
+ let ePersonId;
+ let ePersonEmail;
+
+ beforeEach(() => {
+ ePersonId = 'testEPersonId';
+ ePersonEmail = 'person.email@4science.it';
+ component.epersonInitial = Object.assign(new EPerson(), {
+ id: ePersonId,
+ email: ePersonEmail
+ });
+ component.resetPassword();
+ });
+
+ it('should call epersonRegistrationService.registerEmail', () => {
+ expect(epersonRegistrationService.registerEmail).toHaveBeenCalledWith(ePersonEmail);
+ });
+ });
});
diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts
index 8e248a17d8..0d6d9feaec 100644
--- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts
+++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts
@@ -34,6 +34,8 @@ import { NoContent } from '../../../core/shared/NoContent.model';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { followLink } from '../../../shared/utils/follow-link-config.model';
import { ValidateEmailNotTaken } from './validators/email-taken.validator';
+import { Registration } from '../../../core/shared/registration.model';
+import { EpersonRegistrationService } from '../../../core/data/eperson-registration.service';
@Component({
selector: 'ds-eperson-form',
@@ -167,17 +169,20 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
*/
emailValueChangeSubscribe: Subscription;
- constructor(protected changeDetectorRef: ChangeDetectorRef,
- public epersonService: EPersonDataService,
- public groupsDataService: GroupDataService,
- private formBuilderService: FormBuilderService,
- private translateService: TranslateService,
- private notificationsService: NotificationsService,
- private authService: AuthService,
- private authorizationService: AuthorizationDataService,
- private modalService: NgbModal,
- private paginationService: PaginationService,
- public requestService: RequestService) {
+ constructor(
+ protected changeDetectorRef: ChangeDetectorRef,
+ public epersonService: EPersonDataService,
+ public groupsDataService: GroupDataService,
+ private formBuilderService: FormBuilderService,
+ private translateService: TranslateService,
+ private notificationsService: NotificationsService,
+ private authService: AuthService,
+ private authorizationService: AuthorizationDataService,
+ private modalService: NgbModal,
+ private paginationService: PaginationService,
+ public requestService: RequestService,
+ private epersonRegistrationService: EpersonRegistrationService,
+ ) {
this.subs.push(this.epersonService.getActiveEPerson().subscribe((eperson: EPerson) => {
this.epersonInitial = eperson;
if (hasValue(eperson)) {
@@ -484,6 +489,26 @@ export class EPersonFormComponent implements OnInit, OnDestroy {
this.isImpersonated = false;
}
+ /**
+ * Sends an email to current eperson address with the information
+ * to reset password
+ */
+ resetPassword() {
+ if (hasValue(this.epersonInitial.email)) {
+ this.epersonRegistrationService.registerEmail(this.epersonInitial.email).pipe(getFirstCompletedRemoteData())
+ .subscribe((response: RemoteData) => {
+ if (response.hasSucceeded) {
+ this.notificationsService.success(this.translateService.get('admin.access-control.epeople.actions.reset'),
+ this.translateService.get('forgot-email.form.success.content', {email: this.epersonInitial.email}));
+ } else {
+ this.notificationsService.error(this.translateService.get('forgot-email.form.error.head'),
+ this.translateService.get('forgot-email.form.error.content', {email: this.epersonInitial.email}));
+ }
+ }
+ );
+ }
+ }
+
/**
* Cancel the current edit when component is destroyed & unsub all subscriptions
*/