File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ export class ProfilePageComponent implements OnInit {
161161 } else {
162162 this . notificationsService . error (
163163 this . translate . instant ( this . PASSWORD_NOTIFICATIONS_PREFIX + 'error.title' ) ,
164- this . translate . instant ( this . PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed' )
164+ this . getPasswordErrorMessage ( response )
165165 ) ;
166166 }
167167 } ) ;
@@ -199,4 +199,18 @@ export class ProfilePageComponent implements OnInit {
199199 return this . isResearcherProfileEnabled$ . asObservable ( ) ;
200200 }
201201
202+ /**
203+ * Returns an error message from a password validation request with a specific reason or
204+ * a default message without specific reason.
205+ * @param response from the validation password patch request.
206+ */
207+ getPasswordErrorMessage ( response ) {
208+ if ( response . hasFailed && isNotEmpty ( response . errorMessage ) ) {
209+ // Response has a specific error message. Show this message in the error notification.
210+ return this . translate . instant ( response . errorMessage ) ;
211+ }
212+ // Show default error message notification.
213+ return this . translate . instant ( this . PASSWORD_NOTIFICATIONS_PREFIX + 'error.change-failed' ) ;
214+ }
215+
202216}
You can’t perform that action at this time.
0 commit comments