Skip to content

Commit

Permalink
Show error message from the error response
Browse files Browse the repository at this point in the history
(cherry picked from commit e6546b4)
  • Loading branch information
milanmajchrak authored and github-actions[bot] committed Aug 4, 2023
1 parent 1fd917d commit f746d45
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);

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
}

}

0 comments on commit f746d45

Please sign in to comment.