mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +02:00
Merge branch 'master' of github.com:domify/registry into ssl-cert
Conflicts: CHANGELOG.md
This commit is contained in:
commit
328561cb38
48 changed files with 979 additions and 1229 deletions
|
@ -1,4 +1,3 @@
|
|||
class AdminController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
check_authorization
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
check_authorization unless: :devise_controller?
|
||||
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
|
@ -9,8 +11,14 @@ class ApplicationController < ActionController::Base
|
|||
params[resource] &&= send(method) if respond_to?(method, true)
|
||||
end
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
redirect_to admin_dashboard_path, alert: exception.message
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(_resource)
|
||||
return session[:user_return_to].to_s if session[:user_return_to] && session[:user_return_to] != login_path
|
||||
if session[:user_return_to] && session[:user_return_to] != login_path
|
||||
return session[:user_return_to].to_s
|
||||
end
|
||||
admin_dashboard_path
|
||||
end
|
||||
|
||||
|
@ -34,9 +42,3 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
redirect_to admin_dashboard_path, alert: exception.message
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,188 +1,127 @@
|
|||
class Epp::ContactsController < EppController
|
||||
helper WhodunnitHelper ## Refactor this?
|
||||
|
||||
def create
|
||||
@contact = Contact.new(contact_and_address_attributes)
|
||||
@contact.registrar = current_user.registrar
|
||||
render_epp_response '/epp/contacts/create' and return if @contact.save
|
||||
handle_errors(@contact)
|
||||
end
|
||||
|
||||
def update
|
||||
# FIXME: Update returns 2303 update multiple times
|
||||
code = params_hash['epp']['command']['update']['update'][:id]
|
||||
|
||||
@contact = Contact.where(code: code).first
|
||||
# if update_rights? && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||
if owner? && @contact.update_attributes(contact_and_address_attributes(:update))
|
||||
render_epp_response 'epp/contacts/update'
|
||||
else
|
||||
contact_exists?(code)
|
||||
handle_errors(@contact) and return
|
||||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def delete
|
||||
@contact = find_contact
|
||||
handle_errors(@contact) and return unless rights? # owner?
|
||||
handle_errors(@contact) and return unless @contact
|
||||
handle_errors(@contact) and return unless @contact.destroy_and_clean
|
||||
|
||||
render_epp_response '/epp/contacts/delete'
|
||||
end
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
|
||||
def check
|
||||
ph = params_hash['epp']['command']['check']['check']
|
||||
@contacts = Contact.check_availability(ph[:id])
|
||||
render_epp_response '/epp/contacts/check'
|
||||
end
|
||||
before_action :find_contact, only: [:info, :update, :delete]
|
||||
before_action :find_password, only: [:info, :update, :delete]
|
||||
|
||||
def info
|
||||
handle_errors(@contact) and return unless @contact && rights?
|
||||
# handle_errors(@contact) and return unless rights?
|
||||
@disclosure = ContactDisclosure.default_values.merge(@contact.disclosure.try(:as_hash) || {})
|
||||
@disclosure_policy = @contact.disclosure.try(:attributes_with_flag)
|
||||
@owner = owner?(false)
|
||||
# need to reload contact eagerly
|
||||
@contact = find_contact if @owner # for clarity, could just be true
|
||||
authorize! :info, @contact, @password
|
||||
render_epp_response 'epp/contacts/info'
|
||||
end
|
||||
|
||||
def check
|
||||
authorize! :check, Epp::Contact
|
||||
|
||||
ids = params[:parsed_frame].css('id').map(&:text)
|
||||
@results = Contact.check_availability(ids)
|
||||
render_epp_response '/epp/contacts/check'
|
||||
end
|
||||
|
||||
def create
|
||||
authorize! :create, Epp::Contact
|
||||
|
||||
@contact = Epp::Contact.new(params[:parsed_frame])
|
||||
@contact.registrar = current_user.registrar
|
||||
|
||||
if @contact.save
|
||||
render_epp_response '/epp/contacts/create'
|
||||
else
|
||||
handle_errors(@contact)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
authorize! :update, @contact, @password
|
||||
|
||||
if @contact.update_attributes(params[:parsed_frame])
|
||||
render_epp_response 'epp/contacts/update'
|
||||
else
|
||||
handle_errors(@contact)
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
authorize! :delete, @contact, @password
|
||||
|
||||
if @contact.destroy_and_clean
|
||||
render_epp_response '/epp/contacts/delete'
|
||||
else
|
||||
handle_errors(@contact)
|
||||
end
|
||||
end
|
||||
|
||||
def renew
|
||||
authorize! :renew, Epp::Contact
|
||||
epp_errors << { code: '2101', msg: t(:'errors.messages.unimplemented_command') }
|
||||
handle_errors
|
||||
end
|
||||
|
||||
## HELPER METHODS
|
||||
|
||||
private
|
||||
|
||||
## CREATE
|
||||
def validate_create
|
||||
@ph = params_hash['epp']['command']['create']['create']
|
||||
return false unless validate_params
|
||||
xml_attrs_present?(@ph, [%w(postalInfo name), %w(postalInfo addr city), %w(postalInfo addr cc),
|
||||
%w(ident), %w(voice), %w(email)])
|
||||
|
||||
epp_errors.empty?
|
||||
def find_password
|
||||
@password = params[:parsed_frame].css('authInfo pw').text
|
||||
end
|
||||
|
||||
## UPDATE
|
||||
def validate_updatezz
|
||||
@ph = params_hash['epp']['command']['update']['update']
|
||||
update_attrs_present?
|
||||
# xml_attrs_present?(@ph, [['id'], %w(authInfo pw)])
|
||||
xml_attrs_present?(@ph, [['id']])
|
||||
end
|
||||
|
||||
def contact_exists?(code)
|
||||
return true if @contact.is_a?(Contact)
|
||||
epp_errors << { code: '2303', msg: t('errors.messages.epp_obj_does_not_exist'),
|
||||
value: { obj: 'id', val: code } }
|
||||
end
|
||||
|
||||
def update_attrs_present?
|
||||
return true if params[:parsed_frame].css('add').present?
|
||||
return true if params[:parsed_frame].css('rem').present?
|
||||
return true if params[:parsed_frame].css('chg').present?
|
||||
epp_errors << { code: '2003', msg: I18n.t('errors.messages.required_parameter_missing', key: 'add, rem or chg') }
|
||||
end
|
||||
|
||||
## DELETE
|
||||
def validate_delete
|
||||
@ph = params_hash['epp']['command']['delete']['delete']
|
||||
xml_attrs_present?(@ph, [['id']])
|
||||
end
|
||||
|
||||
## check
|
||||
def validate_check
|
||||
@ph = params_hash['epp']['command']['check']['check']
|
||||
xml_attrs_present?(@ph, [['id']])
|
||||
end
|
||||
|
||||
## info
|
||||
def validate_info # and process
|
||||
@ph = params_hash['epp']['command']['info']['info']
|
||||
return false unless xml_attrs_present?(@ph, [['id']])
|
||||
@contact = find_contact
|
||||
return false unless @contact
|
||||
return true if current_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
|
||||
false
|
||||
end
|
||||
|
||||
## SHARED
|
||||
|
||||
def find_contact
|
||||
contact = Contact.find_by(code: @ph[:id])
|
||||
unless contact
|
||||
epp_errors << { code: '2303',
|
||||
msg: t('errors.messages.epp_obj_does_not_exist'),
|
||||
value: { obj: 'id', val: @ph[:id] } }
|
||||
code = params[:parsed_frame].css('id').text.strip.downcase
|
||||
@contact = Epp::Contact.find_by(code: code)
|
||||
|
||||
if @contact.blank?
|
||||
epp_errors << {
|
||||
code: '2303',
|
||||
msg: t('errors.messages.epp_obj_does_not_exist'),
|
||||
value: { obj: 'id', val: code }
|
||||
}
|
||||
fail CanCan::AccessDenied
|
||||
end
|
||||
contact
|
||||
@contact
|
||||
end
|
||||
|
||||
def owner?(with_errors = true)
|
||||
return false unless find_contact
|
||||
return true if @contact.registrar == current_user.registrar
|
||||
return false unless with_errors
|
||||
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
|
||||
false
|
||||
#
|
||||
# Validations
|
||||
#
|
||||
def validate_info
|
||||
@prefix = 'info > info >'
|
||||
requires 'id'
|
||||
end
|
||||
|
||||
def rights?
|
||||
pw = @ph.try(:[], :authInfo).try(:[], :pw)
|
||||
|
||||
return true if current_user.try(:registrar) == @contact.try(:registrar)
|
||||
return true if pw && @contact.auth_info_matches(pw) # @contact.try(:auth_info_matches, pw)
|
||||
|
||||
epp_errors << { code: '2200', msg: t('errors.messages.epp_authentication_error') }
|
||||
false
|
||||
def validate_check
|
||||
@prefix = 'check > check >'
|
||||
requires 'id'
|
||||
end
|
||||
|
||||
def update_rights?
|
||||
pw = @ph.try(:[], :authInfo).try(:[], :pw)
|
||||
return true if pw && @contact.auth_info_matches(pw)
|
||||
epp_errors << { code: '2200', msg: t('errors.messages.epp_authentication_error') }
|
||||
false
|
||||
end
|
||||
|
||||
def contact_and_address_attributes(type = :create)
|
||||
case type
|
||||
when :update
|
||||
# TODO: support for rem/add
|
||||
contact_hash = merge_attribute_hash(@ph[:chg], type).delete_if { |_k, v| v.empty? }
|
||||
else
|
||||
contact_hash = merge_attribute_hash(@ph, type)
|
||||
end
|
||||
contact_hash[:ident_type] = ident_type unless ident_type.nil?
|
||||
contact_hash
|
||||
end
|
||||
|
||||
def merge_attribute_hash(prms, type)
|
||||
contact_hash = Contact.extract_attributes(prms, type)
|
||||
contact_hash = contact_hash.merge(
|
||||
Address.extract_attributes((prms.try(:[], :postalInfo) || []))
|
||||
def validate_create
|
||||
@prefix = 'create > create >'
|
||||
requires(
|
||||
'postalInfo > name', 'postalInfo > addr > city',
|
||||
'postalInfo > addr > cc', 'ident', 'voice', 'email'
|
||||
)
|
||||
contact_hash[:disclosure_attributes] =
|
||||
ContactDisclosure.extract_attributes(params[:parsed_frame])
|
||||
|
||||
contact_hash
|
||||
ident = params[:parsed_frame].css('ident')
|
||||
if ident.present? && ident.text != 'birthday' && ident.attr('cc').blank?
|
||||
epp_errors << {
|
||||
code: '2003',
|
||||
msg: I18n.t('errors.messages.required_attribute_missing', key: 'ident country code missing')
|
||||
}
|
||||
end
|
||||
@prefix = nil
|
||||
requires 'extension > extdata > legalDocument'
|
||||
end
|
||||
|
||||
def ident_type
|
||||
result = params[:parsed_frame].css('ident').first.try(:attributes).try(:[], 'type').try(:value)
|
||||
return nil unless result
|
||||
|
||||
Contact::IDENT_TYPES.any? { |type| return type if result.include?(type) }
|
||||
nil
|
||||
def validate_update
|
||||
@prefix = 'update > update >'
|
||||
if element_count('chg') == 0 && element_count('rem') == 0 && element_count('add') == 0
|
||||
epp_errors << {
|
||||
code: '2003',
|
||||
msg: I18n.t('errors.messages.required_parameter_missing', key: 'add, rem or chg')
|
||||
}
|
||||
end
|
||||
requires 'id', 'authInfo > pw'
|
||||
@prefix = nil
|
||||
requires 'extension > extdata > legalDocument'
|
||||
end
|
||||
|
||||
def validate_params
|
||||
return true if @ph
|
||||
epp_errors << { code: '2001', msg: t(:'errors.messages.epp_command_syntax_error') }
|
||||
false
|
||||
def validate_delete
|
||||
@prefix = 'delete > delete >'
|
||||
requires 'id', 'authInfo > pw'
|
||||
@prefix = nil
|
||||
requires 'extension > extdata > legalDocument'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Epp::DomainsController < EppController
|
||||
skip_authorization_check # TODO: remove it
|
||||
|
||||
def create
|
||||
@domain = Epp::EppDomain.new(domain_create_params)
|
||||
|
||||
|
@ -206,7 +208,7 @@ class Epp::DomainsController < EppController
|
|||
|
||||
return domain if domain.auth_info == params[:parsed_frame].css('authInfo pw').text
|
||||
|
||||
if (domain.registrar != current_user.registrar && secure[:secure] == true) &&
|
||||
if (domain.registrar != current_user.registrar) && secure[:secure] == true
|
||||
epp_errors << {
|
||||
code: '2302',
|
||||
msg: I18n.t('errors.messages.domain_exists_but_belongs_to_other_registrar'),
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Epp::ErrorsController < EppController
|
||||
skip_authorization_check # TODO: remove it
|
||||
|
||||
def error
|
||||
epp_errors << { code: params[:code], msg: params[:msg] }
|
||||
render_epp_response '/epp/error'
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Epp::KeyrelaysController < EppController
|
||||
skip_authorization_check # TODO: remove it
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def keyrelay
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Epp::PollsController < EppController
|
||||
skip_authorization_check # TODO: remove it
|
||||
|
||||
def poll
|
||||
req_poll if params[:parsed_frame].css('poll').first['op'] == 'req'
|
||||
ack_poll if params[:parsed_frame].css('poll').first['op'] == 'ack'
|
||||
|
@ -38,6 +40,6 @@ class Epp::PollsController < EppController
|
|||
private
|
||||
|
||||
def validate_poll
|
||||
requires_attribute 'poll', 'op', values: %(ack req)
|
||||
requires_attribute 'poll', 'op', values: %(ack req), allow_blank: true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class Epp::SessionsController < EppController
|
||||
skip_authorization_check only: [:hello, :login, :logout]
|
||||
|
||||
def hello
|
||||
render_epp_response('greeting')
|
||||
end
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
class EppController < ApplicationController
|
||||
layout false
|
||||
protect_from_forgery with: :null_session
|
||||
skip_before_action :verify_authenticity_token
|
||||
|
||||
before_action :generate_svtrid
|
||||
before_action :validate_request
|
||||
layout false
|
||||
helper_method :current_user
|
||||
|
||||
rescue_from CanCan::AccessDenied do |_exception|
|
||||
@errors ||= []
|
||||
if @errors.blank?
|
||||
@errors = [{
|
||||
msg: t('errors.messages.epp_authorization_error'),
|
||||
code: '2201'
|
||||
}]
|
||||
end
|
||||
render_epp_response '/epp/error'
|
||||
end
|
||||
|
||||
def generate_svtrid
|
||||
# rubocop: disable Style/VariableName
|
||||
@svTRID = "ccReg-#{format('%010d', rand(10**10))}"
|
||||
|
@ -84,12 +97,19 @@ class EppController < ApplicationController
|
|||
# TODO: Add possibility to pass validations / options in the method
|
||||
|
||||
def requires(*selectors)
|
||||
options = selectors.extract_options!
|
||||
allow_blank = options[:allow_blank] ||= false # allow_blank is false by default
|
||||
|
||||
el, missing = nil, nil
|
||||
selectors.each do |selector|
|
||||
full_selector = [@prefix, selector].compact.join(' ')
|
||||
el = params[:parsed_frame].css(full_selector).first
|
||||
|
||||
missing = el.nil?
|
||||
if allow_blank
|
||||
missing = el.nil?
|
||||
else
|
||||
missing = el.present? ? el.text.blank? : true
|
||||
end
|
||||
epp_errors << {
|
||||
code: '2003',
|
||||
msg: I18n.t('errors.messages.required_parameter_missing', key: full_selector)
|
||||
|
@ -105,7 +125,7 @@ class EppController < ApplicationController
|
|||
# requires_attribute 'transfer', 'op', values: %(approve, query, reject)
|
||||
|
||||
def requires_attribute(element_selector, attribute_selector, options)
|
||||
element = requires(element_selector)
|
||||
element = requires(element_selector, allow_blank: options[:allow_blank])
|
||||
return unless element
|
||||
|
||||
attribute = element[attribute_selector]
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class SessionsController < Devise::SessionsController
|
||||
skip_authorization_check
|
||||
|
||||
def create
|
||||
# TODO: Create ID Card login here:
|
||||
# this is just testing config
|
||||
|
|
|
@ -8,4 +8,13 @@ module ApplicationHelper
|
|||
return '' if unstable_env.nil?
|
||||
"background-image: url(#{image_path(unstable_env.to_s + '.png')});"
|
||||
end
|
||||
|
||||
def ident_indicator(contact)
|
||||
case contact.ident_type
|
||||
when 'birthday'
|
||||
"[#{contact.ident_type}]"
|
||||
else
|
||||
"[#{contact.ident_country_code} #{contact.ident_type}]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
module WhodunnitHelper
|
||||
def link_to_whodunnit(whodunnit)
|
||||
return nil unless whodunnit
|
||||
if whodunnit.include?('-ApiUser')
|
||||
user = ApiUser.find(whodunnit)
|
||||
return link_to(user.username, admin_epp_user_path(user))
|
||||
end
|
||||
user = AdminUser.find(whodunnit)
|
||||
return link_to(user.username, admin_user_path(user))
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
return nil
|
||||
end
|
||||
|
||||
def whodunnit_with_protocol(whodunnit)
|
||||
return nil unless whodunnit
|
||||
if whodunnit.include?('-ApiUser')
|
||||
user = ApiUser.find(whodunnit)
|
||||
return "#{user.username} (EPP)"
|
||||
end
|
||||
user = AdminUser.find(whodunnit)
|
||||
return user.username
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
return nil
|
||||
end
|
||||
end
|
|
@ -2,16 +2,31 @@ class Ability
|
|||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
alias_action :create, :read, :update, :destroy, to: :crud
|
||||
alias_action :show, :create, :update, :destroy, to: :crud
|
||||
|
||||
@user = user || AdminUser.new
|
||||
@user.roles.each { |role| send(role) } if @user.roles
|
||||
|
||||
return if @user.roles || @user.roles.any?
|
||||
|
||||
case @user.class.to_s
|
||||
when 'AdminUser'
|
||||
@user.roles.each { |role| send(role) } if @user.roles
|
||||
when 'ApiUser'
|
||||
epp
|
||||
end
|
||||
|
||||
can :show, :dashboard
|
||||
end
|
||||
|
||||
def epp
|
||||
# Epp::Contact
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
|
||||
can(:check, Epp::Contact)
|
||||
can(:create, Epp::Contact)
|
||||
can(:update, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id && c.auth_info == pw }
|
||||
can(:delete, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id && c.auth_info == pw }
|
||||
can(:renew, Epp::Contact)
|
||||
can(:view_password, Epp::Contact) { |c| c.registrar_id == @user.registrar_id }
|
||||
end
|
||||
|
||||
def user
|
||||
can :show, :dashboard
|
||||
end
|
||||
|
|
|
@ -9,10 +9,15 @@ class ApiUser < User
|
|||
validates :username, :password, :registrar, presence: true
|
||||
validates :username, uniqueness: true
|
||||
|
||||
before_save :create_crt, if: -> (au) { au.csr_changed? }
|
||||
# before_save :create_crt, if: -> (au) { au.csr_changed? }
|
||||
|
||||
attr_accessor :registrar_typeahead
|
||||
|
||||
def ability
|
||||
@ability ||= Ability.new(self)
|
||||
end
|
||||
delegate :can?, :cannot?, to: :ability
|
||||
|
||||
def registrar_typeahead
|
||||
@registrar_typeahead || registrar || nil
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module VersionSession
|
|||
before_save :add_session
|
||||
|
||||
def add_session
|
||||
self.session = PaperSession.session
|
||||
self.session = ::PaperSession.session
|
||||
true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,9 +28,9 @@ module Versions
|
|||
return nil if creator_str.blank?
|
||||
|
||||
if creator_str =~ /^\d-api-/
|
||||
ApiUser.find(creator_str)
|
||||
ApiUser.find_by(id: creator_str)
|
||||
else
|
||||
AdminUser.find(creator_str)
|
||||
AdminUser.find_by(id: creator_str)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,9 +38,9 @@ module Versions
|
|||
return nil if updator_str.blank?
|
||||
|
||||
if updator_str =~ /^\d-api-/
|
||||
ApiUser.find(updator_str)
|
||||
ApiUser.find_by(id: updator_str)
|
||||
else
|
||||
AdminUser.find(updator_str)
|
||||
AdminUser.find_by(id: updator_str)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
class Contact < ActiveRecord::Base
|
||||
include Versions # version/contact_version.rb
|
||||
include EppErrors
|
||||
|
||||
has_one :address, dependent: :destroy
|
||||
has_one :disclosure, class_name: 'ContactDisclosure', dependent: :destroy
|
||||
|
@ -8,45 +7,42 @@ class Contact < ActiveRecord::Base
|
|||
has_many :domain_contacts
|
||||
has_many :domains, through: :domain_contacts
|
||||
has_many :statuses, class_name: 'ContactStatus'
|
||||
has_many :legal_documents, as: :documentable
|
||||
|
||||
belongs_to :registrar
|
||||
|
||||
accepts_nested_attributes_for :address, :disclosure
|
||||
accepts_nested_attributes_for :address, :disclosure, :legal_documents
|
||||
|
||||
validates :name, :phone, :email, :ident, :address, :registrar, :ident_type, presence: true
|
||||
|
||||
# Phone nr validation is very minimam in order to support legacy requirements
|
||||
validates :phone, format: /\+[0-9]{1,3}\.[0-9]{1,14}?/
|
||||
validates :email, format: /@/
|
||||
validates :ident, format: /\d{4}-\d{2}-\d{2}/, if: proc { |c| c.ident_type == 'birthday' }
|
||||
|
||||
validate :ident_must_be_valid
|
||||
|
||||
validates :ident,
|
||||
format: { with: /\d{4}-\d{2}-\d{2}/, message: :invalid_birthday_format },
|
||||
if: proc { |c| c.ident_type == 'birthday' }
|
||||
validates :ident_country_code, presence: true, if: proc { |c| %w(bic priv).include? c.ident_type }
|
||||
validates :code, uniqueness: { message: :epp_id_taken }
|
||||
validate :ident_valid_format?
|
||||
|
||||
delegate :city, to: :address # , prefix: true
|
||||
delegate :street, to: :address # , prefix: true
|
||||
delegate :zip, to: :address # , prefix: true
|
||||
delegate :street, to: :address
|
||||
delegate :city, to: :address
|
||||
delegate :zip, to: :address
|
||||
delegate :state, to: :address
|
||||
delegate :country_code, to: :address
|
||||
delegate :country, to: :address
|
||||
|
||||
# callbacks
|
||||
# TODO: remove old
|
||||
# after_commit :domains_snapshot
|
||||
# after_update :domains_snapshot
|
||||
# after_destroy :domains_snapshot
|
||||
before_validation :set_ident_country_code
|
||||
before_create :generate_code
|
||||
before_create :generate_auth_info
|
||||
after_create :ensure_disclosure
|
||||
|
||||
# scopes
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
|
||||
IDENT_TYPE_ICO = 'ico'
|
||||
IDENT_TYPE_BIC = 'bic'
|
||||
IDENT_TYPES = [
|
||||
IDENT_TYPE_ICO, # Company registry code (or similar)
|
||||
'bic', # Business registry code
|
||||
IDENT_TYPE_BIC, # Company registry code (or similar)
|
||||
'priv', # National idendtification number
|
||||
'op', # Estonian ID, depricated
|
||||
'passport', # Passport number, depricated
|
||||
'birthday' # Birthday date
|
||||
]
|
||||
|
||||
|
@ -54,45 +50,53 @@ class Contact < ActiveRecord::Base
|
|||
CONTACT_TYPE_ADMIN = 'admin'
|
||||
CONTACT_TYPES = [CONTACT_TYPE_TECH, CONTACT_TYPE_ADMIN]
|
||||
|
||||
def ident_must_be_valid
|
||||
# TODO: Ident can also be passport number or company registry code.
|
||||
# so have to make changes to validations (and doc/schema) accordingly
|
||||
return true unless ident.present? && ident_type.present? && ident_type == 'op'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, 'bad format') unless code.valid?
|
||||
class << self
|
||||
def search_by_query(query)
|
||||
res = search(code_cont: query).result
|
||||
res.reduce([]) { |o, v| o << { id: v[:id], display_key: "#{v.name} (#{v.code})" } }
|
||||
end
|
||||
|
||||
def check_availability(codes)
|
||||
codes = [codes] if codes.is_a?(String)
|
||||
|
||||
res = []
|
||||
codes.each do |x|
|
||||
if Contact.find_by(code: x)
|
||||
res << { code: x, avail: 0, reason: 'in use' }
|
||||
else
|
||||
res << { code: x, avail: 1 }
|
||||
end
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
def ident_valid_format?
|
||||
case ident_type
|
||||
when 'priv'
|
||||
case ident_country_code
|
||||
when 'EE'
|
||||
code = Isikukood.new(ident)
|
||||
errors.add(:ident, :invalid_EE_identity_format) unless code.valid?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_disclosure
|
||||
create_disclosure! unless disclosure
|
||||
end
|
||||
|
||||
# TODO: remove old
|
||||
# def domains_snapshot
|
||||
# (domains + domains_owned).uniq.each do |domain|
|
||||
# next unless domain.is_a?(Domain)
|
||||
# # next if domain.versions.last == domain.create_snapshot
|
||||
# domain.create_version # Method from paper_trail
|
||||
# end
|
||||
# end
|
||||
|
||||
def juridical?
|
||||
ident_type == IDENT_TYPE_ICO
|
||||
def bic?
|
||||
ident_type == IDENT_TYPE_BIC
|
||||
end
|
||||
|
||||
def citizen?
|
||||
ident_type != IDENT_TYPE_ICO
|
||||
end
|
||||
|
||||
def cr_id
|
||||
# created_by ? created_by.username : nil
|
||||
end
|
||||
|
||||
def up_id
|
||||
# updated_by ? updated_by.username : nil
|
||||
end
|
||||
|
||||
def auth_info_matches(pw)
|
||||
auth_info == pw
|
||||
def priv?
|
||||
ident_type != IDENT_TYPE_BIC
|
||||
end
|
||||
|
||||
# generate random id for contact
|
||||
|
@ -114,6 +118,8 @@ class Contact < ActiveRecord::Base
|
|||
false
|
||||
end
|
||||
|
||||
# TODO: refactor, it should not allow to destroy with normal destroy,
|
||||
# no need separate method
|
||||
# should use only in transaction
|
||||
def destroy_and_clean
|
||||
if relations_with_domain?
|
||||
|
@ -123,75 +129,13 @@ class Contact < ActiveRecord::Base
|
|||
destroy
|
||||
end
|
||||
|
||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||
{
|
||||
'2302' => [ # Object exists
|
||||
[:code, :epp_id_taken]
|
||||
],
|
||||
'2305' => [ # Association exists
|
||||
[:domains, :exist]
|
||||
],
|
||||
'2005' => [ # Value syntax error
|
||||
[:phone, :invalid],
|
||||
[:email, :invalid],
|
||||
[:ident, :invalid]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
# TODO: remove old
|
||||
# for archiving
|
||||
# def snapshot
|
||||
# {
|
||||
# name: name,
|
||||
# phone: phone,
|
||||
# code: code,
|
||||
# ident: ident,
|
||||
# email: email
|
||||
# }
|
||||
# end
|
||||
|
||||
class << self
|
||||
# non-EPP
|
||||
|
||||
# EPP
|
||||
def extract_attributes(ph, _type = :create)
|
||||
ph[:postalInfo] = ph[:postalInfo].first if ph[:postalInfo].is_a?(Array)
|
||||
contact_hash = {
|
||||
phone: ph[:voice],
|
||||
ident: ph[:ident],
|
||||
ident_type: ph[:ident_type],
|
||||
email: ph[:email],
|
||||
fax: ph[:fax],
|
||||
name: ph[:postalInfo].try(:[], :name),
|
||||
org_name: ph[:postalInfo].try(:[], :org)
|
||||
}
|
||||
# contact_hash[:auth_info] = ph[:authInfo][:pw] if type == :create
|
||||
contact_hash.delete_if { |_k, v| v.nil? }
|
||||
end
|
||||
|
||||
def check_availability(codes)
|
||||
codes = [codes] if codes.is_a?(String)
|
||||
|
||||
res = []
|
||||
codes.each do |x|
|
||||
if Contact.find_by(code: x)
|
||||
res << { code: x, avail: 0, reason: 'in use' }
|
||||
else
|
||||
res << { code: x, avail: 1 }
|
||||
end
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
|
||||
def search_by_query(query)
|
||||
res = search(code_cont: query).result
|
||||
res.reduce([]) { |o, v| o << { id: v[:id], display_key: "#{v.name} (#{v.code})" } }
|
||||
def set_ident_country_code
|
||||
return true unless ident_country_code_changed? && ident_country_code.present?
|
||||
code = Country.new(ident_country_code)
|
||||
if code
|
||||
self.ident_country_code = code.alpha2
|
||||
else
|
||||
errors.add(:ident_country_code, 'is not following ISO_3166-1 alpha 2 format')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,8 +20,6 @@ class Domain < ActiveRecord::Base
|
|||
-> { where(domain_contacts: { contact_type: DomainContact::ADMIN }) },
|
||||
through: :domain_contacts, source: :contact
|
||||
|
||||
# TODO: remove old
|
||||
# has_many :nameservers, dependent: :delete_all, after_add: :track_nameserver_add
|
||||
has_many :nameservers, dependent: :delete_all
|
||||
|
||||
accepts_nested_attributes_for :nameservers, allow_destroy: true,
|
||||
|
@ -42,11 +40,11 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
has_many :legal_documents, as: :documentable
|
||||
|
||||
delegate :code, to: :owner_contact, prefix: true
|
||||
delegate :code, to: :owner_contact, prefix: true
|
||||
delegate :email, to: :owner_contact, prefix: true
|
||||
delegate :ident, to: :owner_contact, prefix: true
|
||||
delegate :phone, to: :owner_contact, prefix: true
|
||||
delegate :name, to: :registrar, prefix: true
|
||||
delegate :name, to: :registrar, prefix: true
|
||||
|
||||
before_create :generate_auth_info
|
||||
before_create :set_validity_dates
|
||||
|
@ -117,11 +115,6 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
attr_accessor :owner_contact_typeahead, :update_me
|
||||
|
||||
# TODO: remove old
|
||||
# archiving
|
||||
# if proc works only on changes on domain sadly
|
||||
# has_paper_trail class_name: 'DomainVersion', meta: { snapshot: :create_snapshot }, if: proc(&:new_version)
|
||||
|
||||
def tech_domain_contacts
|
||||
domain_contacts.select { |x| x.contact_type == DomainContact::TECH }
|
||||
end
|
||||
|
@ -130,52 +123,6 @@ class Domain < ActiveRecord::Base
|
|||
domain_contacts.select { |x| x.contact_type == DomainContact::ADMIN }
|
||||
end
|
||||
|
||||
# TODO: remove old
|
||||
# def new_version
|
||||
# return false if versions.try(:last).try(:snapshot) == create_snapshot
|
||||
# true
|
||||
# end
|
||||
|
||||
# TODO: remove old
|
||||
# def create_version
|
||||
# return true unless PaperTrail.enabled?
|
||||
# return true unless valid?
|
||||
# touch_with_version if new_version
|
||||
# end
|
||||
|
||||
# TODO: remove old
|
||||
# def track_nameserver_add(_nameserver)
|
||||
# return true if versions.count == 0
|
||||
# return true unless valid? && new_version
|
||||
|
||||
# touch_with_version
|
||||
# end
|
||||
|
||||
# TODO: remove old
|
||||
# def create_snapshot
|
||||
# oc = owner_contact.snapshot if owner_contact.is_a?(Contact)
|
||||
# {
|
||||
# owner_contact: oc,
|
||||
# tech_contacts: tech_contacts.map(&:snapshot),
|
||||
# admin_contacts: admin_contacts.map(&:snapshot),
|
||||
# nameservers: nameservers.map(&:snapshot),
|
||||
# domain: make_snapshot
|
||||
# }.to_yaml
|
||||
# end
|
||||
|
||||
# TODO: remove old
|
||||
# def make_snapshot
|
||||
# {
|
||||
# name: name,
|
||||
# status: status,
|
||||
# period: period,
|
||||
# period_unit: period_unit,
|
||||
# registrar_id: registrar.try(:id),
|
||||
# valid_to: valid_to,
|
||||
# valid_from: valid_from
|
||||
# }
|
||||
# end
|
||||
|
||||
def name=(value)
|
||||
value.strip!
|
||||
value.downcase!
|
||||
|
@ -264,7 +211,7 @@ class Domain < ActiveRecord::Base
|
|||
attach_contact(DomainContact::TECH, owner_contact)
|
||||
end
|
||||
|
||||
return unless admin_domain_contacts.count.zero? && owner_contact.citizen?
|
||||
return unless admin_domain_contacts.count.zero? && owner_contact.priv?
|
||||
attach_contact(DomainContact::ADMIN, owner_contact)
|
||||
end
|
||||
|
||||
|
@ -304,36 +251,36 @@ class Domain < ActiveRecord::Base
|
|||
# rubocop:disable Metrics/MethodLength
|
||||
def update_whois_body
|
||||
self.whois_body = <<-EOS
|
||||
This Whois Server contains information on
|
||||
Estonian Top Level Domain ee TLD
|
||||
This Whois Server contains information on
|
||||
Estonian Top Level Domain ee TLD
|
||||
|
||||
domain: #{name}
|
||||
registrar: #{registrar}
|
||||
status:
|
||||
registered:
|
||||
changed: #{updated_at.to_s(:db)}
|
||||
expire:
|
||||
outzone:
|
||||
delete:
|
||||
domain: #{name}
|
||||
registrar: #{registrar}
|
||||
status:
|
||||
registered:
|
||||
changed: #{updated_at.to_s(:db)}
|
||||
expire:
|
||||
outzone:
|
||||
delete:
|
||||
|
||||
contact
|
||||
name:
|
||||
e-mail:
|
||||
registrar:
|
||||
created:
|
||||
contact
|
||||
name:
|
||||
e-mail:
|
||||
registrar:
|
||||
created:
|
||||
|
||||
contact:
|
||||
contact:
|
||||
|
||||
nsset:
|
||||
nserver:
|
||||
nsset:
|
||||
nserver:
|
||||
|
||||
registrar:
|
||||
org:
|
||||
url:
|
||||
phone:
|
||||
address:
|
||||
created:
|
||||
changed:
|
||||
registrar:
|
||||
org:
|
||||
url:
|
||||
phone:
|
||||
address:
|
||||
created:
|
||||
changed:
|
||||
EOS
|
||||
end
|
||||
# rubocop:enabled Metrics/MethodLength
|
||||
|
|
93
app/models/epp/contact.rb
Normal file
93
app/models/epp/contact.rb
Normal file
|
@ -0,0 +1,93 @@
|
|||
# rubocop: disable Metrics/ClassLength
|
||||
class Epp::Contact < Contact
|
||||
include EppErrors
|
||||
|
||||
# disable STI, there is type column present
|
||||
self.inheritance_column = :sti_disabled
|
||||
|
||||
# temp fix
|
||||
has_many :legal_documents, as: :documentable
|
||||
|
||||
class << self
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
def attrs_from(frame)
|
||||
f = frame
|
||||
at = {}.with_indifferent_access
|
||||
at[:name] = f.css('postalInfo name').text if f.css('postalInfo name').present?
|
||||
at[:org_name] = f.css('postalInfo org').text if f.css('postalInfo org').present?
|
||||
at[:email] = f.css('email').text if f.css('email').present?
|
||||
at[:fax] = f.css('fax').text if f.css('fax').present?
|
||||
at[:phone] = f.css('voice').text if f.css('voice').present?
|
||||
at[:auth_info] = f.css('authInfo pw').text if f.css('authInfo pw').present?
|
||||
|
||||
if f.css('ident').present? && f.css('ident').attr('type').present?
|
||||
at[:ident] = f.css('ident').text
|
||||
at[:ident_type] = f.css('ident').attr('type').try(:text)
|
||||
at[:ident_country_code] = f.css('ident').attr('cc').try(:text)
|
||||
end
|
||||
|
||||
at[:address_attributes] = {}.with_indifferent_access
|
||||
sat = at[:address_attributes]
|
||||
sat[:city] = f.css('postalInfo addr city').text if f.css('postalInfo addr city').present?
|
||||
sat[:zip] = f.css('postalInfo addr pc').text if f.css('postalInfo addr pc').present?
|
||||
sat[:street] = f.css('postalInfo addr street').text if f.css('postalInfo addr street').present?
|
||||
sat[:state] = f.css('postalInfo addr sp').text if f.css('postalInfo addr sp').present?
|
||||
sat[:country_code] = f.css('postalInfo addr cc').text if f.css('postalInfo addr cc').present?
|
||||
at.delete(:address_attributes) if at[:address_attributes].blank?
|
||||
|
||||
legal_frame = f.css('legalDocument').first
|
||||
if legal_frame.present?
|
||||
at[:legal_documents_attributes] = legal_document_attrs(legal_frame)
|
||||
end
|
||||
|
||||
at
|
||||
end
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def new(frame)
|
||||
return super if frame.blank?
|
||||
super(attrs_from(frame))
|
||||
end
|
||||
|
||||
def legal_document_attrs(legal_frame)
|
||||
attrs = {}.with_indifferent_access
|
||||
attrs[0] = {}.with_indifferent_access
|
||||
attrs[0][:body] = legal_frame.text
|
||||
attrs[0][:document_type] = legal_frame['type']
|
||||
attrs
|
||||
end
|
||||
end
|
||||
|
||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||
{
|
||||
'2302' => [ # Object exists
|
||||
[:code, :epp_id_taken]
|
||||
],
|
||||
'2305' => [ # Association exists
|
||||
[:domains, :exist]
|
||||
],
|
||||
'2005' => [ # Value syntax error
|
||||
[:phone, :invalid],
|
||||
[:email, :invalid],
|
||||
[:ident, :invalid],
|
||||
[:ident, :invalid_EE_identity_format],
|
||||
[:ident, :invalid_birthday_format]
|
||||
]
|
||||
}
|
||||
end
|
||||
|
||||
def update_attributes(frame)
|
||||
return super if frame.blank?
|
||||
at = {}.with_indifferent_access
|
||||
at.deep_merge!(self.class.attrs_from(frame.css('chg')))
|
||||
legal_frame = frame.css('legalDocument').first
|
||||
at[:legal_documents_attributes] = self.class.legal_document_attrs(legal_frame)
|
||||
|
||||
super(at)
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/ClassLength
|
|
@ -129,7 +129,7 @@ class Epp::EppDomain < Domain
|
|||
next
|
||||
end
|
||||
|
||||
if k == :admin && contact.juridical?
|
||||
if k == :admin && contact.bic?
|
||||
add_epp_error('2306', 'contact', x[:contact], [:domain_contacts, :admin_contact_can_be_only_citizen])
|
||||
next
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
%dd -
|
||||
|
||||
%dt= t('crt')
|
||||
- if @api_user.csr
|
||||
%dd= link_to(t('download'), download_crt_admin_api_user_path)
|
||||
- else
|
||||
%dd -
|
||||
/ - if @api_user.csr
|
||||
/ %dd= link_to(t('download'), download_crt_admin_api_user_path)
|
||||
/ - else
|
||||
/ %dd -
|
||||
|
|
|
@ -22,20 +22,20 @@
|
|||
%thead
|
||||
%tr
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'name', t('name'))
|
||||
= sort_link(@q, 'name', t(:name))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'code', t('code'))
|
||||
= sort_link(@q, 'ident', t(:identity))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'ident', t('identity_code'))
|
||||
= sort_link(@q, 'email', t(:email))
|
||||
%th{class: 'col-xs-2'}
|
||||
= sort_link(@q, 'email', t('email'))
|
||||
= sort_link(@q, 'code', t(:code))
|
||||
%tbody
|
||||
- @contacts.each do |x|
|
||||
- @contacts.each do |contact|
|
||||
%tr
|
||||
%td= link_to(x, admin_contact_path(x))
|
||||
%td= x.code
|
||||
%td= x.ident
|
||||
%td= x.email
|
||||
%td= link_to(contact, admin_contact_path(contact))
|
||||
%td= "#{contact.ident} #{ident_indicator(contact)}"
|
||||
%td= contact.email
|
||||
%td= contact.code
|
||||
.row
|
||||
.col-md-12
|
||||
= paginate @contacts
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t('address')
|
||||
%h3.panel-title= t(:address)
|
||||
.panel-body
|
||||
- unless @contact.address.nil?
|
||||
%dl.dl-horizontal
|
||||
%dt= t('country')
|
||||
%dd= @contact.address.country
|
||||
- if @contact.bic?
|
||||
%dt= t(:org_name)
|
||||
%dd= @contact.org_name
|
||||
|
||||
%dt= t('city')
|
||||
%dd= @contact.address.city
|
||||
%dt= t(:street)
|
||||
%dd= @contact.street
|
||||
|
||||
%dt= t('street')
|
||||
%dd= @contact.address.street
|
||||
%dt= t(:city)
|
||||
%dd= @contact.city
|
||||
|
||||
- if @contact.address.street2
|
||||
%dt= t('street')
|
||||
%dd= @contact.address.street2
|
||||
%dt= t(:zip)
|
||||
%dd= @contact.zip
|
||||
|
||||
- if @contact.address.street3
|
||||
%dt= t('street')
|
||||
%dd= @contact.address.street3
|
||||
|
||||
|
||||
|
||||
%dt= t('zip')
|
||||
%dd= @contact.address.zip
|
||||
%dt= t(:state)
|
||||
%dd= @contact.state
|
||||
|
||||
%dt= t(:country)
|
||||
%dd= @contact.country
|
||||
|
|
|
@ -3,30 +3,25 @@
|
|||
%h3.panel-title= t('general')
|
||||
.panel-body
|
||||
%dl.dl-horizontal
|
||||
%dt= t('name')
|
||||
%dd= @contact.name
|
||||
%dt= t(:ident)
|
||||
%dd= "#{@contact.ident} #{ident_indicator(@contact)}"
|
||||
|
||||
%dt= t('org_name')
|
||||
%dd= @contact.org_name
|
||||
%br
|
||||
|
||||
%dt= t('code')
|
||||
%dd= @contact.code
|
||||
|
||||
%dt= t('ident')
|
||||
%dd= @contact.ident
|
||||
|
||||
%dt= t('ident_type')
|
||||
%dd= @contact.ident_type
|
||||
|
||||
%dt= t('email')
|
||||
%dt= t(:email)
|
||||
%dd= @contact.email
|
||||
|
||||
%dt= t('phone')
|
||||
%dt= t(:phone)
|
||||
%dd= @contact.phone
|
||||
|
||||
- if @contact.fax
|
||||
%dt= t('fax')
|
||||
%dt= t(:fax)
|
||||
%dd= @contact.fax
|
||||
|
||||
%br
|
||||
|
||||
%dt= t(:code)
|
||||
%dd= @contact.code
|
||||
|
||||
%dt= t('password')
|
||||
%dd= @contact.auth_info
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
.row
|
||||
.col-sm-12
|
||||
%h2.text-center-xs
|
||||
= "#{t('contact_details')}"
|
||||
= @contact.name
|
||||
%hr
|
||||
.row
|
||||
.col-md-6= render 'admin/contacts/partials/general'
|
||||
.col-md-6= render 'admin/contacts/partials/address'
|
||||
.row
|
||||
.col-md-12= render 'admin/contacts/partials/domains'
|
||||
.row
|
||||
.col-md-12
|
||||
= render 'admin/domains/partials/legal_documents', legal_documents: @contact.legal_documents
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
%th{class: 'col-xs-8'}= t('created_at')
|
||||
%th{class: 'col-xs-4'}= t('type')
|
||||
%tbody
|
||||
- @domain.legal_documents.each do |x|
|
||||
- legal_documents.each do |x|
|
||||
%tr
|
||||
%td= link_to(x.created_at, [:admin, x])
|
||||
%td= x.document_type
|
||||
|
|
|
@ -24,4 +24,5 @@
|
|||
.row
|
||||
.col-md-12= render 'admin/domains/partials/keyrelays'
|
||||
.row
|
||||
.col-md-12= render 'admin/domains/partials/legal_documents'
|
||||
.col-md-12
|
||||
= render 'admin/domains/partials/legal_documents', legal_documents: @domain.legal_documents
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
address = @contact.address
|
||||
xml.tag!('contact:postalInfo', type: 'int') do
|
||||
xml.tag!('contact:name', @contact.name) if @disclosure.try(:[], :name) || @owner
|
||||
xml.tag!('contact:org', @contact.org_name) if @disclosure.try(:[], :org_name) || @owner
|
||||
if @disclosure.try(:addr) || @owner
|
||||
xml.tag!('contact:name', @contact.name) #if @disclosure.try(:[], :name) || @owner
|
||||
xml.tag!('contact:org', @contact.org_name) #if @disclosure.try(:[], :org_name) || @owner
|
||||
# if @disclosure.try(:addr) || @owner
|
||||
xml.tag!('contact:addr') do
|
||||
xml.tag!('contact:street', address.street) if address
|
||||
xml.tag!('contact:cc', address.country_code) unless address.country_code.nil?
|
||||
xml.tag!('contact:city', address.city) if address
|
||||
xml.tag!('contact:street', @contact.street)
|
||||
xml.tag!('contact:city', @contact.city)
|
||||
xml.tag!('contact:pc', @contact.zip)
|
||||
xml.tag!('contact:sp', @contact.state)
|
||||
xml.tag!('contact:cc', @contact.country_code)
|
||||
end
|
||||
end
|
||||
# end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,11 +6,10 @@ xml.epp_head do
|
|||
|
||||
xml.resData do
|
||||
xml.tag!('contact:chkData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
|
||||
#xml.tag!('contact:id', @contact.code)
|
||||
@contacts.each do |contact|
|
||||
@results.each do |result|
|
||||
xml.tag!('contact:cd') do
|
||||
xml.tag! "contact:id", contact[:code], avail: contact[:avail]
|
||||
xml.tag!('contact:reason', contact[:reason]) unless contact[:avail] == 1
|
||||
xml.tag! "contact:id", result[:code], avail: result[:avail]
|
||||
xml.tag!('contact:reason', result[:reason]) unless result[:avail] == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,9 +8,9 @@ xml.epp_head do
|
|||
xml.tag!('contact:chkData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
|
||||
xml.tag!('contact:id', @contact.code)
|
||||
xml << render('/epp/contacts/postal_info')
|
||||
xml.tag!('contact:voice', @contact.phone) if @disclosure.try(:phone) || @owner
|
||||
xml.tag!('contact:fax', @contact.fax) if @disclosure.try(:fax) || @owner
|
||||
xml.tag!('contact:email', @contact.email) if @disclosure.try(:email) || @owner
|
||||
xml.tag!('contact:voice', @contact.phone) #if @disclosure.try(:phone) || @owner
|
||||
xml.tag!('contact:fax', @contact.fax) #if @disclosure.try(:fax) || @owner
|
||||
xml.tag!('contact:email', @contact.email) #if @disclosure.try(:email) || @owner
|
||||
xml.tag!('contact:clID', @contact.registrar.try(:name))
|
||||
xml.tag!('contact:crID', @contact.creator.try(:registrar))
|
||||
xml.tag!('contact:crDate', @contact.created_at)
|
||||
|
@ -19,17 +19,16 @@ xml.epp_head do
|
|||
xml.tag!('contact:upDate', @contact.updated_at)
|
||||
end
|
||||
xml.tag!('contact:ident', @contact.ident, type: @contact.ident_type)
|
||||
xml.tag!('contact:trDate', '123') if false
|
||||
if @owner
|
||||
# xml.tag!('contact:trDate', '123') if false
|
||||
if can? :view_password, @contact
|
||||
xml.tag!('contact:authInfo') do
|
||||
xml.tag!('contact:pw', @contact.auth_info) # Doc says we have to return this but is it necessary?
|
||||
xml.tag!('contact:pw', @contact.auth_info)
|
||||
end
|
||||
end
|
||||
# statuses
|
||||
@contact.statuses.each do |cs|
|
||||
xml.tag!('contact:status', s: cs.value)
|
||||
@contact.statuses.each do |status|
|
||||
xml.tag!('contact:status', s: status.value)
|
||||
end
|
||||
xml << render('/epp/contacts/disclosure_policy')
|
||||
# xml << render('/epp/contacts/disclosure_policy')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue