diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index b261d63364e..f357046bb18 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -59,6 +59,7 @@ class ConfigurePageComponent extends AuthComponent { this.state = { configuration: {}, credentials: {credentialsData: [], errors: [], id: null}, + credentialsErrors: [], masqueStrings: {}, currentFormData: {}, importCandidateConfig: null, @@ -409,6 +410,20 @@ class ConfigurePageComponent extends AuthComponent { ) .then(res => { if (!res.ok) { + res.json().then((result)=>{ + let errorMessages = result.errors.map(error => { + return `${error.message.split(', ').pop()}`; + }); + const messageCountMap = {}; + errorMessages.map((message) => { + messageCountMap[message] = (messageCountMap[message] || 0) + 1; + }); + this.setState({ + credentialsErrors: Object.entries(messageCountMap) + .map(([errorMessage, count]) => + (count > 1 ? `${count} ${_.lowerFirst(errorMessage)}` : `${errorMessage}`)) + }); + }); throw Error() } return res; @@ -573,6 +588,11 @@ class ConfigurePageComponent extends AuthComponent {
An invalid configuration file was imported or submitted. One or more of the credentials are invalid. + { this.state.credentialsErrors.length !== 0 ? + : '' + }
: ''} {this.state.lastAction === 'invalid_configuration' ?