mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Show error message from the error response
(cherry picked from commit e6546b4499
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
1fd917dd4a
commit
f746d45ac1
@@ -161,7 +161,7 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(
|
this.notificationsService.error(
|
||||||
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.title'),
|
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.title'),
|
||||||
this.translate.instant(this.PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed')
|
this.getPasswordErrorMessage(response)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -199,4 +199,18 @@ export class ProfilePageComponent implements OnInit {
|
|||||||
return this.isResearcherProfileEnabled$.asObservable();
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user