Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Port dspace-7_x] Show error message from the password validation response #2419

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
} 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 @@
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);

Check warning on line 210 in src/app/profile-page/profile-page.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/profile-page/profile-page.component.ts#L210

Added line #L210 was not covered by tests
}
// Show default error message notification.
return this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed');

Check warning on line 213 in src/app/profile-page/profile-page.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/profile-page/profile-page.component.ts#L213

Added line #L213 was not covered by tests
}

}
Loading