Fixed bug: Invalid API keys are validated as correct.
This commit is contained in:
parent
ea10d24c38
commit
437023ac79
1 changed files with 20 additions and 11 deletions
|
@ -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,16 +42,27 @@ class ImportOtrsController < ApplicationController
|
|||
result = {}
|
||||
if response.body =~ /zammad migrator/
|
||||
|
||||
key_parts = url_parts[1].split('=')
|
||||
migrator_response = JSON.parse(response.body)
|
||||
|
||||
Setting.set('import_backend', 'otrs')
|
||||
Setting.set('import_otrs_endpoint', url_parts[0])
|
||||
Setting.set('import_otrs_endpoint_key', key_parts[1])
|
||||
if migrator_response['Success'] == 1
|
||||
|
||||
result = {
|
||||
result: 'ok',
|
||||
url: params[:url],
|
||||
}
|
||||
url_parts = params[:url].split(';')
|
||||
key_parts = url_parts[1].split('=')
|
||||
|
||||
Setting.set('import_backend', 'otrs')
|
||||
Setting.set('import_otrs_endpoint', url_parts[0])
|
||||
Setting.set('import_otrs_endpoint_key', key_parts[1])
|
||||
|
||||
result = {
|
||||
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',
|
||||
|
|
Loading…
Reference in a new issue