mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #2378 from dataquest-dev/show_password_error
Show error message from the password validation response
This commit is contained in:
@@ -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