mirror of
https://github.com/internetee/registry.git
synced 2025-06-09 22:24:47 +02:00
39 lines
1.2 KiB
Ruby
39 lines
1.2 KiB
Ruby
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: 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 << { code: '2304', msg: 'New contact must be valid' } if @new_contact.invalid?
|
|
|
|
if @new_contact == @current_contact
|
|
@epp_errors << { code: '2304', msg: 'New contact must be different from current' }
|
|
end
|
|
|
|
affected, skipped = TechDomainContact.replace(@current_contact, @new_contact)
|
|
data = { affected_domains: affected, skipped_domains: skipped }
|
|
render_success(data: data)
|
|
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
|