mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
Merge branch 'registry-918' into registry-922
This commit is contained in:
commit
e3807f694d
4 changed files with 5 additions and 5 deletions
|
@ -21,7 +21,7 @@ module Api
|
||||||
if token
|
if token
|
||||||
render json: token
|
render json: token
|
||||||
else
|
else
|
||||||
render json: { error: 'Cannot create generate session token' }
|
render json: { errors: [{ base: ['Cannot create generate session token'] }] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ module Api
|
||||||
allowed_ips = ENV['registrant_api_auth_allowed_ips'].to_s.split(',').map(&:strip)
|
allowed_ips = ENV['registrant_api_auth_allowed_ips'].to_s.split(',').map(&:strip)
|
||||||
return if allowed_ips.include?(request.ip) || Rails.env.development?
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Api
|
||||||
if decryptor.valid?
|
if decryptor.valid?
|
||||||
sign_in decryptor.user
|
sign_in decryptor.user
|
||||||
else
|
else
|
||||||
render json: { errors: ['Not authorized'] }, status: :unauthorized
|
render json: { errors: [{base: ['Not authorized']}] }, status: :unauthorized
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,7 @@ class RegistrantApiAuthenticationTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal(401, response.status)
|
assert_equal(401, response.status)
|
||||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
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
|
ENV['registrant_api_auth_allowed_ips'] = @original_whitelist_ip
|
||||||
end
|
end
|
||||||
|
|
|
@ -81,7 +81,7 @@ class RegistrantApiDomainsTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal(401, response.status)
|
assert_equal(401, response.status)
|
||||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
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
|
end
|
||||||
|
|
||||||
def test_details_returns_401_without_authorization
|
def test_details_returns_401_without_authorization
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue