diff --git a/app/controllers/api/v1/registrant/auth_controller.rb b/app/controllers/api/v1/registrant/auth_controller.rb index 5be48f558..929d5b5c9 100644 --- a/app/controllers/api/v1/registrant/auth_controller.rb +++ b/app/controllers/api/v1/registrant/auth_controller.rb @@ -21,7 +21,7 @@ module Api if token render json: token else - render json: { error: 'Cannot create generate session token' } + render json: { errors: [{ base: ['Cannot create generate session token'] }] } end end @@ -46,7 +46,7 @@ module Api allowed_ips = ENV['registrant_api_auth_allowed_ips'].to_s.split(',').map(&:strip) return if allowed_ips.include?(request.ip) || Rails.env.development? - render json: { errors: ['Not authorized'] }, status: :unauthorized + render json: { errors: [{ base: ['Not authorized'] }] }, status: :unauthorized end end end diff --git a/app/controllers/api/v1/registrant/base_controller.rb b/app/controllers/api/v1/registrant/base_controller.rb index bc5fa21d7..4df0d226c 100644 --- a/app/controllers/api/v1/registrant/base_controller.rb +++ b/app/controllers/api/v1/registrant/base_controller.rb @@ -29,7 +29,7 @@ module Api if decryptor.valid? sign_in decryptor.user else - render json: { errors: ['Not authorized'] }, status: :unauthorized + render json: { errors: [{base: ['Not authorized']}] }, status: :unauthorized end end end diff --git a/test/integration/api/registrant/registrant_api_authentication_test.rb b/test/integration/api/registrant/registrant_api_authentication_test.rb index 14ef1c879..97651b029 100644 --- a/test/integration/api/registrant/registrant_api_authentication_test.rb +++ b/test/integration/api/registrant/registrant_api_authentication_test.rb @@ -42,7 +42,7 @@ class RegistrantApiAuthenticationTest < ActionDispatch::IntegrationTest assert_equal(401, response.status) json_body = JSON.parse(response.body, symbolize_names: true) - assert_equal({ errors: ['Not authorized'] }, json_body) + assert_equal({ errors: [base: ['Not authorized']] }, json_body) ENV['registrant_api_auth_allowed_ips'] = @original_whitelist_ip end diff --git a/test/integration/api/registrant/registrant_api_domains_test.rb b/test/integration/api/registrant/registrant_api_domains_test.rb index 3e966b192..1c77131c4 100644 --- a/test/integration/api/registrant/registrant_api_domains_test.rb +++ b/test/integration/api/registrant/registrant_api_domains_test.rb @@ -81,7 +81,7 @@ class RegistrantApiDomainsTest < ActionDispatch::IntegrationTest assert_equal(401, response.status) json_body = JSON.parse(response.body, symbolize_names: true) - assert_equal({ errors: ['Not authorized'] }, json_body) + assert_equal({ errors: [base: ['Not authorized']] }, json_body) end def test_details_returns_401_without_authorization