mirror of
https://github.com/internetee/registry.git
synced 2025-07-19 17:25:57 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
5cb4b35e0f
6 changed files with 47 additions and 17 deletions
|
@ -16,15 +16,17 @@ class Ability
|
|||
can :show, :dashboard
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def epp
|
||||
# Epp::Contact
|
||||
can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
|
||||
can(:info, Epp::Contact)
|
||||
can(:view_full_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 }
|
||||
can(:view_password, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw }
|
||||
|
||||
# Epp::Domain
|
||||
can(:info, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
|
@ -34,6 +36,7 @@ class Ability
|
|||
can(:update, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.auth_info == pw }
|
||||
can(:transfer, Epp::Domain) { |d, pw| d.auth_info == pw }
|
||||
end
|
||||
# rubocop: enabled Metrics/CyclomaticComplexity
|
||||
|
||||
def user
|
||||
can :show, :dashboard
|
||||
|
|
|
@ -40,6 +40,14 @@ class Contact < ActiveRecord::Base
|
|||
before_create :generate_code
|
||||
before_create :generate_auth_info
|
||||
after_create :ensure_disclosure
|
||||
after_save :manage_automatic_statuses
|
||||
def manage_automatic_statuses
|
||||
if statuses.empty? && valid?
|
||||
statuses.create(value: ContactStatus::OK)
|
||||
elsif statuses.length > 1 || !valid?
|
||||
statuses.find_by(value: ContactStatus::OK).try(:destroy)
|
||||
end
|
||||
end
|
||||
|
||||
scope :current_registrars, ->(id) { where(registrar_id: id) }
|
||||
|
||||
|
|
|
@ -7,19 +7,23 @@ xml.epp_head do
|
|||
xml.resData do
|
||||
xml.tag!('contact:infData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
|
||||
xml.tag!('contact:id', @contact.code)
|
||||
xml.tag!('contact:voice', @contact.phone)
|
||||
xml.tag!('contact:email', @contact.email)
|
||||
xml.tag!('contact:fax', @contact.fax) if @contact.fax.present?
|
||||
if can? :view_full_info, @contact, @password
|
||||
xml.tag!('contact:voice', @contact.phone)
|
||||
xml.tag!('contact:email', @contact.email)
|
||||
xml.tag!('contact:fax', @contact.fax) if @contact.fax.present?
|
||||
end
|
||||
|
||||
xml.tag!('contact:postalInfo', type: 'int') do
|
||||
xml.tag!('contact:name', @contact.name)
|
||||
xml.tag!('contact:org', @contact.org_name) if @contact.org_name.present?
|
||||
xml.tag!('contact:addr') do
|
||||
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)
|
||||
if can? :view_full_info, @contact, @password
|
||||
xml.tag!('contact:org', @contact.org_name) if @contact.org_name.present?
|
||||
xml.tag!('contact:addr') do
|
||||
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
|
||||
|
||||
|
@ -32,7 +36,7 @@ xml.epp_head do
|
|||
end
|
||||
xml.tag!('contact:ident', @contact.ident, type: @contact.ident_type, cc: @contact.ident_country_code)
|
||||
# xml.tag!('contact:trDate', '123') if false
|
||||
if can? :view_password, @contact
|
||||
if can? :view_password, @contact, @password
|
||||
xml.tag!('contact:authInfo') do
|
||||
xml.tag!('contact:pw', @contact.auth_info)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue