Skip to content

Commit

Permalink
Merge pull request DSpace#2419 from DSpace/backport-2378-to-dspace-7_x
Browse files Browse the repository at this point in the history
[Port dspace-7_x] Show error message from the password validation response
  • Loading branch information
alanorth authored Aug 4, 2023
2 parents 1fd917d + f746d45 commit d072ae7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/app/profile-page/profile-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class ProfilePageComponent implements OnInit {
} else {
this.notificationsService.error(
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.title'),
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed')
this.getPasswordErrorMessage(response)
);
}
});
Expand Down Expand Up @@ -199,4 +199,18 @@ export class ProfilePageComponent implements OnInit {
return this.isResearcherProfileEnabled$.asObservable();
}

/**
* Returns an error message from a password validation request with a specific reason or
* a default message without specific reason.
* @param response from the validation password patch request.
*/
getPasswordErrorMessage(response) {
if (response.hasFailed && isNotEmpty(response.errorMessage)) {
// Response has a specific error message. Show this message in the error notification.
return this.translate.instant(response.errorMessage);
}
// Show default error message notification.
return this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed');
}

}

0 comments on commit d072ae7

Please sign in to comment.