mirror of
https://github.com/internetee/registry.git
synced 2025-06-05 20:27:30 +02:00
REPP: Show error when invalid ident format submitted
This commit is contained in:
parent
3d0150076c
commit
03db562c77
4 changed files with 9 additions and 4 deletions
|
@ -4,6 +4,7 @@ module Repp
|
|||
rescue_from ActiveRecord::RecordNotFound, with: :not_found_error
|
||||
before_action :authenticate_user
|
||||
before_action :check_ip_restriction
|
||||
before_action :set_paper_trail_whodunnit
|
||||
attr_reader :current_user
|
||||
|
||||
rescue_from ActionController::ParameterMissing do |exception|
|
||||
|
|
|
@ -112,7 +112,7 @@ module Repp
|
|||
end
|
||||
|
||||
def contact_ident_params(required: true)
|
||||
if required || !params[:contact][:ident].nil?
|
||||
if required
|
||||
params.require(:contact).require(:ident).require(%i[ident ident_type ident_country_code])
|
||||
params.require(:contact).require(:ident).permit(:ident, :ident_type, :ident_country_code)
|
||||
else
|
||||
|
|
|
@ -17,7 +17,7 @@ module Actions
|
|||
def call
|
||||
maybe_remove_address
|
||||
maybe_update_statuses
|
||||
maybe_update_ident if ident
|
||||
maybe_update_ident if ident.present?
|
||||
maybe_attach_legal_doc
|
||||
commit
|
||||
end
|
||||
|
@ -53,7 +53,11 @@ module Actions
|
|||
end
|
||||
|
||||
def maybe_update_ident
|
||||
return unless ident[:ident]
|
||||
unless ident.is_a?(Hash)
|
||||
contact.add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.valid_ident'))
|
||||
@error = true
|
||||
return
|
||||
end
|
||||
|
||||
if contact.identifier.valid?
|
||||
submitted_ident = ::Contact::Ident.new(code: ident[:ident],
|
||||
|
|
|
@ -28,7 +28,7 @@ class ReppV1ContactsShowTest < ActionDispatch::IntegrationTest
|
|||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal contact.code, json[:data][:code]
|
||||
assert_equal contact.code, json[:data][:id]
|
||||
end
|
||||
|
||||
def test_can_not_access_out_of_scope_contacts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue