Refactor EPP users to API users

This commit is contained in:
Martin Lensment 2015-01-29 14:13:49 +02:00
parent b8494993ea
commit c91c9c8ebf
44 changed files with 154 additions and 150 deletions

View file

@ -3,12 +3,12 @@ class Epp::ContactsController < EppController
helper WhodunnitHelper ## Refactor this?
def user_for_paper_trail ## Refactor this?
current_epp_user ? "#{current_epp_user.id}-EppUser" : nil
current_api_user ? "#{current_api_user.id}-ApiUser" : nil
end
def create
@contact = Contact.new(contact_and_address_attributes)
@contact.registrar = current_epp_user.registrar
@contact.registrar = current_api_user.registrar
render_epp_response '/epp/contacts/create' and return if stamp(@contact) && @contact.save
handle_errors(@contact)
end
@ -113,7 +113,7 @@ class Epp::ContactsController < EppController
return false unless xml_attrs_present?(@ph, [['id']])
@contact = find_contact
return false unless @contact
return true if current_epp_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
return true if current_api_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
false
end
@ -135,7 +135,7 @@ class Epp::ContactsController < EppController
def owner?(with_errors = true)
return false unless find_contact
return true if @contact.registrar == current_epp_user.registrar
return true if @contact.registrar == current_api_user.registrar
return false unless with_errors
epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error') }
false
@ -144,7 +144,7 @@ class Epp::ContactsController < EppController
def rights?
pw = @ph.try(:[], :authInfo).try(:[], :pw)
return true if current_epp_user.try(:registrar) == @contact.try(:registrar)
return true if current_api_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') }