From c87f75cc970047551718890368f6ad742113ac0b Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 3 Nov 2017 11:36:41 +0100 Subject: [PATCH 1/3] Added placeholder for better usability. --- .../javascripts/app/views/integration/exchange_wizard.jst.eco | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco b/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco index df23bb0b4..8b1161c35 100644 --- a/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco +++ b/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco @@ -19,7 +19,7 @@ <%- @T('User') %> - + <%- @T('Password') %> From 3fc78c657cf3cf9c89e8548b9f038c40cb03942b Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 3 Nov 2017 11:40:11 +0100 Subject: [PATCH 2/3] Exchange changes: - Fixed bug: Not possible to disable SSL certificate check for import but only for autodiscover. - Improved SSL certificate error message to show domain of affected domain to prevent users from thinking that there is an issue with their Zammad installation. --- .../controllers/_integration/exchange.coffee | 99 +++++++++++++------ .../exchange_certificate_issue.jst.eco | 25 +++++ .../views/integration/exchange_wizard.jst.eco | 25 +---- .../integration/exchange_controller.rb | 27 +++-- lib/sequencer/unit/exchange/connection.rb | 33 ++++++- 5 files changed, 138 insertions(+), 71 deletions(-) create mode 100644 app/assets/javascripts/app/views/integration/exchange_certificate_issue.jst.eco diff --git a/app/assets/javascripts/app/controllers/_integration/exchange.coffee b/app/assets/javascripts/app/controllers/_integration/exchange.coffee index 3bfbde4c7..c02c541ba 100644 --- a/app/assets/javascripts/app/controllers/_integration/exchange.coffee +++ b/app/assets/javascripts/app/controllers/_integration/exchange.coffee @@ -174,17 +174,18 @@ class ConnectionWizard extends App.WizardModal 'js-mapping': 'mappingShow' events: - 'submit form.js-discover': 'discover' - 'submit form.js-discoverSsl': 'discover' - 'submit form.js-bind': 'folders' - 'submit form.js-folders': 'mapping' - 'click .js-cancelSsl': 'showSlideDiscover' - 'click .js-mapping .js-submitTry': 'mappingChange' - 'click .js-try .js-submitSave': 'save' - 'click .js-close': 'hide' - 'click .js-remove': 'removeRow' - 'click .js-userMappingForm .js-add': 'addUserMapping' - 'click .js-goToSlide': 'goToSlide' + 'submit form.js-discover': 'discover' + 'submit form.js-discoverCertificateIssue': 'discover' + 'submit form.js-bind': 'folders' + 'submit form.js-bindCertificateIssue': 'folders' + 'submit form.js-folders': 'mapping' + 'click .js-cancelSsl': 'showSlideDiscover' + 'click .js-mapping .js-submitTry': 'mappingChange' + 'click .js-try .js-submitSave': 'save' + 'click .js-close': 'hide' + 'click .js-remove': 'removeRow' + 'click .js-userMappingForm .js-add': 'addUserMapping' + 'click .js-goToSlide': 'goToSlide' elements: '.modal-body': 'body' @@ -261,20 +262,17 @@ class ConnectionWizard extends App.WizardModal processData: true success: (data, status, xhr) => if data.result isnt 'ok' - - if data.message.indexOf('certificate') is -1 - @showSlide('js-discover') - @showAlert('js-discover', data.message) - else - @$('.js-discoverSsl input[name="user"]').val(params.user) - @$('.js-discoverSsl input[name="password"]').val(params.password) - @showSlide('js-discoverSsl') - + @handleCertificateIssue( + message: data.message + wizardClass: 'js-discover' + user: params.user + password: params.password + ) return - @wizardConfig.endpoint = data.endpoint - @wizardConfig.user = params.user - @wizardConfig.password = params.password + @wizardConfig.disable_ssl_verify = params.disable_ssl_verify + @wizardConfig.user = params.user + @wizardConfig.password = params.password @showSlide('js-bind') @showBindDetails() @@ -300,13 +298,19 @@ class ConnectionWizard extends App.WizardModal processData: true success: (data, status, xhr) => if data.result isnt 'ok' - @showSlide('js-bind') - @showAlert('js-bind', data.message) + @handleCertificateIssue( + message: data.message + wizardClass: 'js-bind' + endpoint: params.endpoint + user: params.user + password: params.password + ) return - @wizardConfig.endpoint = params.endpoint - @wizardConfig.user = params.user - @wizardConfig.password = params.password + @wizardConfig.disable_ssl_verify = params.disable_ssl_verify + @wizardConfig.endpoint = params.endpoint + @wizardConfig.user = params.user + @wizardConfig.password = params.password # update wizard data @wizardConfig.wizardData = {} @@ -341,6 +345,45 @@ class ConnectionWizard extends App.WizardModal @foldersSelectSubmit.addClass('is-disabled') ) + handleCertificateIssue: (params) => + if params.message.indexOf('certificate') is -1 + @showSlide(params.wizardClass) + @showAlert(params.wizardClass, params.message) + else + wizardClass = "#{params.wizardClass}CertificateIssue" + + domain = @domainFromMessageOrEmail( + message: params.message + user: params.user + ) + + wizardSlide = App.view('integration/exchange_certificate_issue')( + wizardClass: wizardClass + endpoint: params.endpoint + user: params.user + password: params.password + domain: domain + ) + + @$('.js-certificateIssuePlaceholder').html(wizardSlide) + + @showSlide(wizardClass) + + domainFromMessageOrEmail: (params) -> + + # try to extract the hostname from the error message + hostname = params.message.match(/hostname[ ]\"([^\"]+)"/i) + if hostname + return hostname[1] + + # try to extract it from the given user + emailDomain = params.user.match(/@(.*)$/) + if emailDomain + return emailDomain[1] + + # fallback to user - better than no value?! + return user + mapping: (e) => e.preventDefault() @showSlide('js-analyze') diff --git a/app/assets/javascripts/app/views/integration/exchange_certificate_issue.jst.eco b/app/assets/javascripts/app/views/integration/exchange_certificate_issue.jst.eco new file mode 100644 index 000000000..1f3c01b83 --- /dev/null +++ b/app/assets/javascripts/app/views/integration/exchange_certificate_issue.jst.eco @@ -0,0 +1,25 @@ + diff --git a/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco b/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco index 8b1161c35..d47ccaca9 100644 --- a/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco +++ b/app/assets/javascripts/app/views/integration/exchange_wizard.jst.eco @@ -34,30 +34,7 @@ - +