mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
Fix CC issues
This commit is contained in:
parent
da032dad79
commit
f6a2d91d61
5 changed files with 41 additions and 46 deletions
|
@ -1,21 +1,9 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Domains
|
||||
class AdminContactsController < BaseController
|
||||
before_action :set_current_contact, only: [:update]
|
||||
before_action :set_new_contact, only: [:update]
|
||||
|
||||
def set_current_contact
|
||||
@current_contact = current_user.registrar.contacts.find_by!(code: contact_params[:current_contact_id])
|
||||
end
|
||||
|
||||
def set_new_contact
|
||||
@new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id])
|
||||
end
|
||||
|
||||
class AdminContactsController < BaseContactsController
|
||||
def update
|
||||
@epp_errors ||= []
|
||||
@epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid?
|
||||
super
|
||||
|
||||
unless @new_contact.identical_to?(@current_contact)
|
||||
@epp_errors << { code: 2304, msg: 'Admin contacts must be identical' }
|
||||
|
@ -27,13 +15,6 @@ module Repp
|
|||
@response = { affected_domains: affected, skipped_domains: skipped }
|
||||
render_success(data: @response)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def contact_params
|
||||
params.require(%i[current_contact_id new_contact_id])
|
||||
params.permit(:current_contact_id, :new_contact_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
31
app/controllers/repp/v1/domains/base_contacts_controller.rb
Normal file
31
app/controllers/repp/v1/domains/base_contacts_controller.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Domains
|
||||
class BaseContactsController < BaseController
|
||||
before_action :set_current_contact, only: [:update]
|
||||
before_action :set_new_contact, only: [:update]
|
||||
|
||||
def set_current_contact
|
||||
@current_contact = current_user.registrar.contacts
|
||||
.find_by!(code: contact_params[:current_contact_id])
|
||||
end
|
||||
|
||||
def set_new_contact
|
||||
@new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id])
|
||||
end
|
||||
|
||||
def update
|
||||
@epp_errors ||= []
|
||||
@epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def contact_params
|
||||
params.require(%i[current_contact_id new_contact_id])
|
||||
params.permit(:current_contact_id, :new_contact_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,23 +1,9 @@
|
|||
module Repp
|
||||
module V1
|
||||
module Domains
|
||||
class ContactsController < BaseController
|
||||
before_action :set_current_contact, only: [:update]
|
||||
before_action :set_new_contact, only: [:update]
|
||||
|
||||
def set_current_contact
|
||||
@current_contact = current_user.registrar.contacts.find_by!(
|
||||
code: contact_params[:current_contact_id]
|
||||
)
|
||||
end
|
||||
|
||||
def set_new_contact
|
||||
@new_contact = current_user.registrar.contacts.find_by!(code: params[:new_contact_id])
|
||||
end
|
||||
|
||||
class ContactsController < BaseContactsController
|
||||
def update
|
||||
@epp_errors ||= []
|
||||
@epp_errors << { code: 2304, msg: 'New contact must be valid' } if @new_contact.invalid?
|
||||
super
|
||||
|
||||
if @new_contact == @current_contact
|
||||
@epp_errors << { code: 2304, msg: 'New contact must be different from current' }
|
||||
|
@ -29,13 +15,6 @@ module Repp
|
|||
@response = { affected_domains: affected, skipped_domains: skipped }
|
||||
render_success(data: @response)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def contact_params
|
||||
params.require(%i[current_contact_id new_contact_id])
|
||||
params.permit(:current_contact_id, :new_contact_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class AdminDomainContact < DomainContact
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def self.replace(current_contact, new_contact)
|
||||
affected_domains = []
|
||||
skipped_domains = []
|
||||
|
@ -19,4 +21,6 @@ class AdminDomainContact < DomainContact
|
|||
end
|
||||
[affected_domains.sort, skipped_domains.sort]
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Concerns::Contact::Identical
|
|||
ident
|
||||
ident_type
|
||||
ident_country_code
|
||||
]
|
||||
].freeze
|
||||
|
||||
private_constant :IDENTIFIABLE_ATTRIBUTES
|
||||
|
||||
|
@ -29,7 +29,7 @@ module Concerns::Contact::Identical
|
|||
|
||||
def identical_to?(contact)
|
||||
IDENTICAL_ATTRIBUTES.all? do |attribute|
|
||||
self.attributes[attribute] == contact.attributes[attribute]
|
||||
attributes[attribute] == contact.attributes[attribute]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue