From 0a73875d17d7cebbc5fcb7c907e55c6ad320c63d Mon Sep 17 00:00:00 2001 From: nikunj59 Date: Tue, 21 Jun 2022 21:42:33 +0530 Subject: [PATCH 01/73] CST-6110 changes for robust password error --- .../profile-page-security-form.component.html | 1 + ...rofile-page-security-form.component.spec.ts | 13 +++++++++++++ .../profile-page-security-form.component.ts | 6 ++++++ .../profile-page/profile-page.component.html | 1 + src/app/profile-page/profile-page.component.ts | 5 ++++- .../create-profile.component.html | 1 + .../create-profile.component.spec.ts | 18 ++++++++++++++++++ .../create-profile/create-profile.component.ts | 8 +++++--- src/assets/i18n/en.json5 | 4 ++++ 9 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.html b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.html index 7c1dff5bdf..66c9d73be2 100644 --- a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.html +++ b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.html @@ -9,3 +9,4 @@
{{FORM_PREFIX + 'error.password-length' | translate}}
{{FORM_PREFIX + 'error.matching-passwords' | translate}}
{{FORM_PREFIX + 'error.empty-password' | translate}}
+
{{FORM_PREFIX + 'error.robust-password' | translate}}
diff --git a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts index 213a83b86e..e8fd4740eb 100644 --- a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts +++ b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.spec.ts @@ -9,6 +9,7 @@ import { FormBuilderService } from '../../shared/form/builder/form-builder.servi import { ProfilePageSecurityFormComponent } from './profile-page-security-form.component'; import { of as observableOf } from 'rxjs'; import { RestResponse } from '../../core/cache/response.models'; +import { By } from '@angular/platform-browser'; describe('ProfilePageSecurityFormComponent', () => { let component: ProfilePageSecurityFormComponent; @@ -76,4 +77,16 @@ describe('ProfilePageSecurityFormComponent', () => { })); }); }); + + describe('On robust password Error', () => { + it('should show/hide robust password error', () => { + component.isRobustPasswordError = true; + fixture.detectChanges(); + expect(fixture.debugElement.query(By.css('[data-test="robust-password-error"]'))).toBeTruthy(); + + component.isRobustPasswordError = false; + fixture.detectChanges(); + expect(fixture.debugElement.query(By.css('[data-test="robust-password-error"]'))).toBeFalsy(); + }) + }); }); diff --git a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.ts b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.ts index 4f310204e3..1eacb9f1be 100644 --- a/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.ts +++ b/src/app/profile-page/profile-page-security-form/profile-page-security-form.component.ts @@ -60,6 +60,12 @@ export class ProfilePageSecurityFormComponent implements OnInit { */ @Input() FORM_PREFIX: string; + + /** + * monitor to password is weak or not from server response + */ + @Input() + isRobustPasswordError: boolean; private subs: Subscription[] = []; constructor(protected formService: DynamicFormService, diff --git a/src/app/profile-page/profile-page.component.html b/src/app/profile-page/profile-page.component.html index 6e22f73a75..63c34d02b3 100644 --- a/src/app/profile-page/profile-page.component.html +++ b/src/app/profile-page/profile-page.component.html @@ -24,6 +24,7 @@ [FORM_PREFIX]="'profile.security.form.'" (isInvalid)="setInvalid($event)" (passwordValue)="setPasswordValue($event)" + [isRobustPasswordError]="isRobustPasswordError | async" > diff --git a/src/app/profile-page/profile-page.component.ts b/src/app/profile-page/profile-page.component.ts index 5629a1ae18..5762192e92 100644 --- a/src/app/profile-page/profile-page.component.ts +++ b/src/app/profile-page/profile-page.component.ts @@ -73,6 +73,7 @@ export class ProfilePageComponent implements OnInit { */ private currentUser: EPerson; canChangePassword$: Observable; + isRobustPasswordError: BehaviorSubject = new BehaviorSubject(false); isResearcherProfileEnabled$: BehaviorSubject = new BehaviorSubject(false); @@ -147,7 +148,9 @@ export class ProfilePageComponent implements OnInit { this.epersonService.patch(this.currentUser, [operation]).pipe( getFirstCompletedRemoteData() ).subscribe((response: RemoteData) => { - if (response.hasSucceeded) { + if (response.statusCode === 422) { + this.isRobustPasswordError.next(true); + } else if (response.hasSucceeded) { this.notificationsService.success( this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.title'), this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.content') diff --git a/src/app/register-page/create-profile/create-profile.component.html b/src/app/register-page/create-profile/create-profile.component.html index f56059ad69..5ef17c6b64 100644 --- a/src/app/register-page/create-profile/create-profile.component.html +++ b/src/app/register-page/create-profile/create-profile.component.html @@ -73,6 +73,7 @@ [FORM_PREFIX]="'register-page.create-profile.security.'" (isInvalid)="setInValid($event)" (passwordValue)="setPasswordValue($event)" + [isRobustPasswordError]="isRobustPasswordError | async" > diff --git a/src/app/register-page/create-profile/create-profile.component.spec.ts b/src/app/register-page/create-profile/create-profile.component.spec.ts index b95e380e08..d2d4c4c0ee 100644 --- a/src/app/register-page/create-profile/create-profile.component.spec.ts +++ b/src/app/register-page/create-profile/create-profile.component.spec.ts @@ -238,6 +238,24 @@ describe('CreateProfileComponent', () => { expect(router.navigate).not.toHaveBeenCalled(); expect(notificationsService.error).toHaveBeenCalled(); }); + + it('should submit an eperson for creation but password is weak', () => { + + (ePersonDataService.createEPersonForToken as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Error', 422)); + + comp.firstName.patchValue('First'); + comp.lastName.patchValue('Last'); + comp.contactPhone.patchValue('Phone'); + comp.language.patchValue('en'); + comp.password = 'password'; + comp.isInValidPassword = false; + + comp.submitEperson(); + + expect(ePersonDataService.createEPersonForToken).toHaveBeenCalledWith(eperson, 'test-token'); + expect(comp.isRobustPasswordError.value).toBeTrue(); + }); + it('should submit not create an eperson when the user info form is invalid', () => { (ePersonDataService.createEPersonForToken as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Error', 500)); diff --git a/src/app/register-page/create-profile/create-profile.component.ts b/src/app/register-page/create-profile/create-profile.component.ts index d042e63ece..ff71e1ee01 100644 --- a/src/app/register-page/create-profile/create-profile.component.ts +++ b/src/app/register-page/create-profile/create-profile.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { map } from 'rxjs/operators'; import { Registration } from '../../core/shared/registration.model'; -import { Observable } from 'rxjs'; +import { BehaviorSubject, Observable } from 'rxjs'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { TranslateService } from '@ngx-translate/core'; import { EPersonDataService } from '../../core/eperson/eperson-data.service'; @@ -40,7 +40,7 @@ export class CreateProfileComponent implements OnInit { userInfoForm: FormGroup; activeLangs: LangConfig[]; - + isRobustPasswordError: BehaviorSubject = new BehaviorSubject(false); constructor( private translateService: TranslateService, private ePersonDataService: EPersonDataService, @@ -160,7 +160,9 @@ export class CreateProfileComponent implements OnInit { this.ePersonDataService.createEPersonForToken(eperson, this.token).pipe( getFirstCompletedRemoteData(), ).subscribe((rd: RemoteData) => { - if (rd.hasSucceeded) { + if (rd.statusCode === 422) { + this.isRobustPasswordError.next(true); + } else if (rd.hasSucceeded) { this.notificationsService.success(this.translateService.get('register-page.create-profile.submit.success.head'), this.translateService.get('register-page.create-profile.submit.success.content')); this.store.dispatch(new AuthenticateAction(this.email, this.password)); diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index cb664e19f7..bf5ccb4f06 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3056,6 +3056,8 @@ "profile.security.form.notifications.error.not-same": "The provided passwords are not the same.", + "profile.security.form.notifications.error.robust-password": "Please select a more robust password.", + "profile.title": "Update Profile", "profile.card.researcher": "Researcher Profile", @@ -3146,6 +3148,8 @@ "register-page.create-profile.security.error.empty-password": "Please enter a password in the box below.", + "register-page.create-profile.security.error.robust-password": "Please select a more robust password.", + "register-page.create-profile.security.error.matching-passwords": "The passwords do not match.", "register-page.create-profile.security.error.password-length": "The password should be at least 6 characters long.", From 17a89387f290da1ba4a6c6829c96881fa77314b0 Mon Sep 17 00:00:00 2001 From: nikunj59 Date: Wed, 22 Jun 2022 13:03:06 +0530 Subject: [PATCH 02/73] CST-6110 changes for robust password error --- .../profile-page/profile-page.component.spec.ts | 17 +++++++++++++++++ src/assets/i18n/en.json5 | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/profile-page/profile-page.component.spec.ts b/src/app/profile-page/profile-page.component.spec.ts index 6893ac2437..bd85448566 100644 --- a/src/app/profile-page/profile-page.component.spec.ts +++ b/src/app/profile-page/profile-page.component.spec.ts @@ -228,6 +228,23 @@ describe('ProfilePageComponent', () => { expect(epersonService.patch).toHaveBeenCalledWith(user, operations); }); }); + + describe('when password is filled in, and is weak', () => { + let result; + let operations; + + it('should return call epersonService.patch', () => { + (epersonService.patch as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Error', 422)); + component.setPasswordValue('testest'); + + component.setInvalid(false); + operations = [{ op: 'add', path: '/password', value: 'testest' }]; + result = component.updateSecurity(); + expect(result).toEqual(true); + expect(epersonService.patch).toHaveBeenCalledWith(user, operations); + expect(component.isRobustPasswordError.value).toBeTrue(); + }); + }); }); describe('canChangePassword$', () => { diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index bf5ccb4f06..353912a6b7 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3056,7 +3056,7 @@ "profile.security.form.notifications.error.not-same": "The provided passwords are not the same.", - "profile.security.form.notifications.error.robust-password": "Please select a more robust password.", + "profile.security.form.error.robust-password": "Please select a more robust password.", "profile.title": "Update Profile", From 7afa4dcd8dc426ed10b54c8d3edc116ecdc50f74 Mon Sep 17 00:00:00 2001 From: Michael Spalti Date: Thu, 4 Aug 2022 11:21:14 -0700 Subject: [PATCH 03/73] New themable components --- .../community-page.component.html | 3 +- .../community-page/community-page.module.ts | 8 ++++++ ...nity-page-sub-collection-list.component.ts | 7 ++++- ...nity-page-sub-collection-list.component.ts | 28 +++++++++++++++++++ ...unity-page-sub-community-list.component.ts | 9 ++++-- ...unity-page-sub-community-list.component.ts | 28 +++++++++++++++++++ ...ty-page-sub-collection-list.component.html | 0 ...ty-page-sub-collection-list.component.scss | 0 ...nity-page-sub-collection-list.component.ts | 12 ++++++++ ...ity-page-sub-community-list.component.html | 0 ...ity-page-sub-community-list.component.scss | 0 ...unity-page-sub-community-list.component.ts | 12 ++++++++ src/themes/custom/eager-theme.module.ts | 2 +- src/themes/custom/lazy-theme.module.ts | 11 ++++++++ 14 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 src/app/community-page/sub-collection-list/themed-community-page-sub-collection-list.component.ts create mode 100644 src/app/community-page/sub-community-list/themed-community-page-sub-community-list.component.ts create mode 100644 src/themes/custom/app/community-page/sub-collection-list/community-page-sub-collection-list.component.html create mode 100644 src/themes/custom/app/community-page/sub-collection-list/community-page-sub-collection-list.component.scss create mode 100644 src/themes/custom/app/community-page/sub-collection-list/community-page-sub-collection-list.component.ts create mode 100644 src/themes/custom/app/community-page/sub-community-list/community-page-sub-community-list.component.html create mode 100644 src/themes/custom/app/community-page/sub-community-list/community-page-sub-community-list.component.scss create mode 100644 src/themes/custom/app/community-page/sub-community-list/community-page-sub-community-list.component.ts diff --git a/src/app/community-page/community-page.component.html b/src/app/community-page/community-page.component.html index 6b277bd07f..314a14658d 100644 --- a/src/app/community-page/community-page.component.html +++ b/src/app/community-page/community-page.component.html @@ -25,11 +25,12 @@
+ - +