Skip to content

Commit

Permalink
Merge pull request #2378 from dataquest-dev/show_password_error
Browse files Browse the repository at this point in the history
Show error message from the password validation response
  • Loading branch information
alanorth authored Aug 4, 2023
2 parents 0fca4e0 + e6546b4 commit 2cfd19f
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 2cfd19f

Please sign in to comment.