diff --git a/src/app/forgot-password/forgot-password-form/forgot-password-form.component.html b/src/app/forgot-password/forgot-password-form/forgot-password-form.component.html index f3bc9005c6..5fb0006279 100644 --- a/src/app/forgot-password/forgot-password-form/forgot-password-form.component.html +++ b/src/app/forgot-password/forgot-password-form/forgot-password-form.component.html @@ -21,7 +21,6 @@ [FORM_PREFIX]="'forgot-password.form.'" (isInvalid)="setInValid($event)" (passwordValue)="setPasswordValue($event)" - [isRobustPasswordError]="isRobustPasswordError | async" > diff --git a/src/app/forgot-password/forgot-password-form/forgot-password-form.component.spec.ts b/src/app/forgot-password/forgot-password-form/forgot-password-form.component.spec.ts index a618e7b46d..68566efaec 100644 --- a/src/app/forgot-password/forgot-password-form/forgot-password-form.component.spec.ts +++ b/src/app/forgot-password/forgot-password-form/forgot-password-form.component.spec.ts @@ -1,4 +1,4 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { of as observableOf } from 'rxjs'; import { RouterStub } from '../../shared/testing/router.stub'; import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; @@ -109,21 +109,6 @@ describe('ForgotPasswordFormComponent', () => { expect(notificationsService.error).toHaveBeenCalled(); }); - it('should submit a patch request for the user uuid and get robust password error stay on page', () => { - - (ePersonDataService.patchPasswordWithToken as jasmine.Spy).and.returnValue(createFailedRemoteDataObject$('Error', 422)); - - comp.password = 'password'; - comp.isInValid = false; - - comp.submit(); - - expect(ePersonDataService.patchPasswordWithToken).toHaveBeenCalledWith('test-uuid', 'test-token', 'password'); - expect(store.dispatch).not.toHaveBeenCalled(); - expect(router.navigate).not.toHaveBeenCalled(); - expect(comp.isRobustPasswordError.value).toBeTrue(); - }); - it('should submit a patch request for the user uuid when the form is invalid', () => { comp.password = 'password'; diff --git a/src/app/forgot-password/forgot-password-form/forgot-password-form.component.ts b/src/app/forgot-password/forgot-password-form/forgot-password-form.component.ts index 5e4439fa20..e20683e6e3 100644 --- a/src/app/forgot-password/forgot-password-form/forgot-password-form.component.ts +++ b/src/app/forgot-password/forgot-password-form/forgot-password-form.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { EPersonDataService } from '../../core/eperson/eperson-data.service'; import { TranslateService } from '@ngx-translate/core'; import { NotificationsService } from '../../shared/notifications/notifications.service'; -import { BehaviorSubject, Observable } from 'rxjs'; +import { Observable } from 'rxjs'; import { Registration } from '../../core/shared/registration.model'; import { map } from 'rxjs/operators'; import { ActivatedRoute, Router } from '@angular/router'; @@ -10,10 +10,7 @@ import { AuthenticateAction } from '../../core/auth/auth.actions'; import { Store } from '@ngrx/store'; import { RemoteData } from '../../core/data/remote-data'; import { EPerson } from '../../core/eperson/models/eperson.model'; -import { - getFirstCompletedRemoteData, - getFirstSucceededRemoteDataPayload, -} from '../../core/shared/operators'; +import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload, } from '../../core/shared/operators'; import { CoreState } from '../../core/core-state.model'; @Component({ @@ -39,7 +36,6 @@ export class ForgotPasswordFormComponent { * Prefix for the notification messages of this component */ NOTIFICATIONS_PREFIX = 'forgot-password.form.notification'; - isRobustPasswordError: BehaviorSubject = new BehaviorSubject(false); constructor(private ePersonDataService: EPersonDataService, private translateService: TranslateService, @@ -68,7 +64,6 @@ export class ForgotPasswordFormComponent { setPasswordValue($event: string) { this.password = $event; - this.isRobustPasswordError.next(false); } /** @@ -80,9 +75,7 @@ export class ForgotPasswordFormComponent { this.ePersonDataService.patchPasswordWithToken(this.user, this.token, this.password).pipe( getFirstCompletedRemoteData() ).subscribe((response: RemoteData) => { - if (response.statusCode === 422) { - this.isRobustPasswordError.next(true); - } else if (response.hasSucceeded) { + if (response.hasSucceeded) { this.notificationsService.success( this.translateService.instant(this.NOTIFICATIONS_PREFIX + '.success.title'), this.translateService.instant(this.NOTIFICATIONS_PREFIX + '.success.content') 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 976ff88eda..0f944e0016 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 @@ -6,7 +6,5 @@ [displaySubmit]="false" [displayCancel]="false"> -
{{FORM_PREFIX + 'error.password-length' | translate}}
{{FORM_PREFIX + 'error.matching-passwords' | translate}}
{{FORM_PREFIX + 'error.empty-password' | translate}}
-
{{'password.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 621d67cab6..dd7a1d8655 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 @@ -1,4 +1,4 @@ -import { waitForAsync, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { VarDirective } from '../../shared/utils/var.directive'; import { TranslateModule } from '@ngx-translate/core'; @@ -9,7 +9,6 @@ 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; @@ -77,16 +76,4 @@ 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 83548a09d7..ecee22303f 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 @@ -61,11 +61,6 @@ 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, @@ -77,10 +72,10 @@ export class ProfilePageSecurityFormComponent implements OnInit { ngOnInit(): void { if (this.passwordCanBeEmpty) { this.formGroup = this.formService.createFormGroup(this.formModel, - {validators: [this.checkPasswordsEqual, this.checkPasswordLength]}); + { validators: [this.checkPasswordsEqual] }); } else { this.formGroup = this.formService.createFormGroup(this.formModel, - {validators: [this.checkPasswordsEqual, this.checkPasswordLength, this.checkPasswordEmpty]}); + { validators: [this.checkPasswordsEqual, this.checkPasswordEmpty] }); } this.updateFieldTranslations(); this.translate.onLangChange @@ -88,15 +83,11 @@ export class ProfilePageSecurityFormComponent implements OnInit { this.updateFieldTranslations(); }); - this.subs.push(this.formGroup.statusChanges.pipe( - debounceTime(300), - map((status: string) => { - if (status !== 'VALID') { - return true; - } else { - return false; - } - })).subscribe((status) => this.isInvalid.emit(status)) + this.subs.push( + this.formGroup.statusChanges.pipe( + debounceTime(300), + map((status: string) => status !== 'VALID') + ).subscribe((status) => this.isInvalid.emit(status)) ); this.subs.push(this.formGroup.valueChanges.pipe( @@ -125,17 +116,7 @@ export class ProfilePageSecurityFormComponent implements OnInit { const pass = group.get('password').value; const repeatPass = group.get('passwordrepeat').value; - return pass === repeatPass ? null : {notSame: true}; - } - - /** - * Check if the password is at least 8 characters long - * @param group The FormGroup to validate - */ - checkPasswordLength(group: FormGroup) { - const pass = group.get('password').value; - - return isEmpty(pass) || pass.length >= 8 ? null : {notLongEnough: true}; + return pass === repeatPass ? null : { notSame: true }; } /** @@ -144,7 +125,7 @@ export class ProfilePageSecurityFormComponent implements OnInit { */ checkPasswordEmpty(group: FormGroup) { const pass = group.get('password').value; - return isEmpty(pass) ? {emptyPassword: true} : null; + return isEmpty(pass) ? { emptyPassword: true } : null; } /** diff --git a/src/app/profile-page/profile-page.component.html b/src/app/profile-page/profile-page.component.html index 63c34d02b3..6e22f73a75 100644 --- a/src/app/profile-page/profile-page.component.html +++ b/src/app/profile-page/profile-page.component.html @@ -24,7 +24,6 @@ [FORM_PREFIX]="'profile.security.form.'" (isInvalid)="setInvalid($event)" (passwordValue)="setPasswordValue($event)" - [isRobustPasswordError]="isRobustPasswordError | async" > diff --git a/src/app/profile-page/profile-page.component.spec.ts b/src/app/profile-page/profile-page.component.spec.ts index bd85448566..6893ac2437 100644 --- a/src/app/profile-page/profile-page.component.spec.ts +++ b/src/app/profile-page/profile-page.component.spec.ts @@ -228,23 +228,6 @@ 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/app/profile-page/profile-page.component.ts b/src/app/profile-page/profile-page.component.ts index 940422628d..5629a1ae18 100644 --- a/src/app/profile-page/profile-page.component.ts +++ b/src/app/profile-page/profile-page.component.ts @@ -73,7 +73,6 @@ export class ProfilePageComponent implements OnInit { */ private currentUser: EPerson; canChangePassword$: Observable; - isRobustPasswordError: BehaviorSubject = new BehaviorSubject(false); isResearcherProfileEnabled$: BehaviorSubject = new BehaviorSubject(false); @@ -148,9 +147,7 @@ export class ProfilePageComponent implements OnInit { this.epersonService.patch(this.currentUser, [operation]).pipe( getFirstCompletedRemoteData() ).subscribe((response: RemoteData) => { - if (response.statusCode === 422) { - this.isRobustPasswordError.next(true); - } else if (response.hasSucceeded) { + if (response.hasSucceeded) { this.notificationsService.success( this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.title'), this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'success.content') @@ -171,7 +168,6 @@ export class ProfilePageComponent implements OnInit { */ setPasswordValue($event: string) { this.password = $event; - this.isRobustPasswordError.next(false); } /** 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 5ef17c6b64..f56059ad69 100644 --- a/src/app/register-page/create-profile/create-profile.component.html +++ b/src/app/register-page/create-profile/create-profile.component.html @@ -73,7 +73,6 @@ [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 d2d4c4c0ee..026785e59b 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 @@ -239,23 +239,6 @@ describe('CreateProfileComponent', () => { 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 09449b9be8..d042e63ece 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 { BehaviorSubject, Observable } from 'rxjs'; +import { 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, @@ -93,7 +93,6 @@ export class CreateProfileComponent implements OnInit { setPasswordValue($event: string) { this.password = $event; this.isInValidPassword = this.isInValidPassword || isEmpty(this.password); - this.isRobustPasswordError.next(false); } get firstName() { @@ -161,9 +160,7 @@ export class CreateProfileComponent implements OnInit { this.ePersonDataService.createEPersonForToken(eperson, this.token).pipe( getFirstCompletedRemoteData(), ).subscribe((rd: RemoteData) => { - if (rd.statusCode === 422) { - this.isRobustPasswordError.next(true); - } else if (rd.hasSucceeded) { + 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 75cf0c9cca..a78a094d8f 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1490,7 +1490,7 @@ "forgot-password.form.head": "Forgot Password", - "forgot-password.form.info": "Enter a new password in the box below, and confirm it by typing it again into the second box. It should be at least eight characters long.", + "forgot-password.form.info": "Enter a new password in the box below, and confirm it by typing it again into the second box.", "forgot-password.form.card.security": "Security", @@ -1506,8 +1506,6 @@ "forgot-password.form.error.matching-passwords": "The passwords do not match.", - "forgot-password.form.error.password-length": "The password should be at least 8 characters long.", - "forgot-password.form.notification.error.title": "Error when trying to submit new password", "forgot-password.form.notification.success.content": "The password reset was successful. You have been logged in as the created user.", @@ -1516,8 +1514,6 @@ "forgot-password.form.submit": "Submit password", - "password.error.robust-password": "New password is invalid. Valid passwords must be between 8-15 characters long and must include a minimum of: one uppercase letter, one lowercase letter, one number, and one special character (!?$@#$%^&+=).", - "form.add": "Add more", @@ -2985,7 +2981,7 @@ "process.detail.create" : "Create similar process", "process.detail.actions": "Actions", - + "process.detail.delete.button": "Delete process", "process.detail.delete.header": "Delete process", @@ -3038,7 +3034,7 @@ "process.bulk.delete.success": "{{count}} process(es) have been succesfully deleted", - + "profile.breadcrumbs": "Update Profile", @@ -3078,9 +3074,7 @@ "profile.security.form.error.matching-passwords": "The passwords do not match.", - "profile.security.form.error.password-length": "The password should be at least 8 characters long.", - - "profile.security.form.info": "Optionally, you can enter a new password in the box below, and confirm it by typing it again into the second box. It should be at least eight characters long.", + "profile.security.form.info": "Optionally, you can enter a new password in the box below, and confirm it by typing it again into the second box.", "profile.security.form.label.password": "Password", @@ -3180,7 +3174,7 @@ "register-page.create-profile.security.header": "Security", - "register-page.create-profile.security.info": "Please enter a password in the box below, and confirm it by typing it again into the second box. It should be at least eight characters long.", + "register-page.create-profile.security.info": "Please enter a password in the box below, and confirm it by typing it again into the second box.", "register-page.create-profile.security.label.password": "Password *", @@ -3190,8 +3184,6 @@ "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 8 characters long.", - "register-page.create-profile.submit": "Complete Registration", "register-page.create-profile.submit.error.content": "Something went wrong while registering a new user.",