mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 21:46:24 +02:00
disclose attributes validator
This commit is contained in:
parent
1b92bf0d64
commit
ea2fc01a60
3 changed files with 42 additions and 22 deletions
|
@ -50,6 +50,13 @@ module Api
|
|||
reparsed_request = reparsed_request(request.body.string)
|
||||
disclosed_attributes = reparsed_request[:disclosed_attributes]
|
||||
|
||||
if disclosed_attributes.present?
|
||||
extra_attrs = disclosed_attributes - Contact::DISCLOSE_ATTRIBUTES
|
||||
attributes_not_exist_error(extra_attrs) and return if extra_attrs.present?
|
||||
end
|
||||
|
||||
# render_disclosed_attributes_error and return if disclosed_attributes.present? && contact.org?
|
||||
|
||||
contact.disclosed_attributes = disclosed_attributes if disclosed_attributes
|
||||
publishable = reparsed_request[:registrant_publishable]
|
||||
contact.registrant_publishable = publishable if publishable.in? [true, false]
|
||||
|
@ -116,6 +123,11 @@ module Api
|
|||
)
|
||||
end
|
||||
|
||||
def attributes_not_exist_error(extra_attrs)
|
||||
error_msg = "Request contains extra attributes: #{extra_attrs.join(', ')}"
|
||||
render json: { errors: [{ disclosed_attributes: [error_msg] }] }, status: :bad_request
|
||||
end
|
||||
|
||||
def render_address_error
|
||||
error_msg = 'Address processing is disabled and therefore cannot be updated'
|
||||
render json: { errors: [{ address: [error_msg] }] }, status: :bad_request
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue