Fixed bug: Invalid API keys are validated as correct.

This commit is contained in:
Thorsten Eckel 2016-01-13 17:14:28 +01:00
parent ea10d24c38
commit 437023ac79

View file

@ -22,9 +22,7 @@ class ImportOtrsController < ApplicationController
'Connection refused' => 'Connection refused!',
}
url_parts = params[:url].split(';')
response = UserAgent.request( url_parts[0] )
response = UserAgent.request( params[:url] )
if !response.success? && response.code.to_s !~ /^40.$/
message_human = ''
@ -44,6 +42,11 @@ class ImportOtrsController < ApplicationController
result = {}
if response.body =~ /zammad migrator/
migrator_response = JSON.parse(response.body)
if migrator_response['Success'] == 1
url_parts = params[:url].split(';')
key_parts = url_parts[1].split('=')
Setting.set('import_backend', 'otrs')
@ -54,6 +57,12 @@ class ImportOtrsController < ApplicationController
result: 'ok',
url: params[:url],
}
else
result = {
result: 'invalid',
message_human: migrator_response['Error']
}
end
elsif response.body =~ /(otrs\sag|otrs\.com|otrs\.org)/i
result = {
result: 'invalid',