Refactor user to admin and api user

This commit is contained in:
Martin Lensment 2015-02-13 16:17:06 +02:00
parent f3215680d5
commit 037cb57e00
34 changed files with 551 additions and 551 deletions

View file

@ -3,7 +3,7 @@ class Epp::ContactsController < EppController
def create
@contact = Contact.new(contact_and_address_attributes)
@contact.registrar = current_api_user.registrar
@contact.registrar = current_user.registrar
render_epp_response '/epp/contacts/create' and return if @contact.save
handle_errors(@contact)
end
@ -108,7 +108,7 @@ class Epp::ContactsController < EppController
return false unless xml_attrs_present?(@ph, [['id']])
@contact = find_contact
return false unless @contact
return true if current_api_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
return true if current_user.registrar == @contact.registrar || xml_attrs_present?(@ph, [%w(authInfo pw)])
false
end
@ -126,7 +126,7 @@ class Epp::ContactsController < EppController
def owner?(with_errors = true)
return false unless find_contact
return true if @contact.registrar == current_api_user.registrar
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
@ -135,7 +135,7 @@ class Epp::ContactsController < EppController
def rights?
pw = @ph.try(:[], :authInfo).try(:[], :pw)
return true if current_api_user.try(:registrar) == @contact.try(:registrar)
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') }

View file

@ -176,7 +176,7 @@ class Epp::DomainsController < EppController
{
name: name,
registrar_id: current_api_user.registrar.try(:id),
registrar_id: current_user.registrar.try(:id),
registered_at: Time.now,
period: (period.to_i == 0) ? 1 : period.to_i,
period_unit: Epp::EppDomain.parse_period_unit_from_frame(params[:parsed_frame]) || 'y'
@ -187,7 +187,7 @@ class Epp::DomainsController < EppController
res = {}
res[:pw] = params[:parsed_frame].css('pw').first.try(:text)
res[:action] = params[:parsed_frame].css('transfer').first[:op]
res[:current_user] = current_api_user
res[:current_user] = current_user
res
end
@ -206,7 +206,7 @@ class Epp::DomainsController < EppController
return domain if domain.auth_info == params[:parsed_frame].css('authInfo pw').text
if (domain.registrar != current_api_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'),

View file

@ -6,7 +6,7 @@ class Epp::KeyrelaysController < EppController
handle_errors(@domain) and return unless @domain
handle_errors(@domain) and return unless @domain.authenticate(params[:parsed_frame].css('pw').text)
handle_errors(@domain) and return unless @domain.keyrelay(params[:parsed_frame], current_api_user.registrar)
handle_errors(@domain) and return unless @domain.keyrelay(params[:parsed_frame], current_user.registrar)
render_epp_response '/epp/shared/success'
end

View file

@ -5,7 +5,7 @@ class Epp::PollsController < EppController
end
def req_poll
@message = current_api_user.queued_messages.last
@message = current_user.queued_messages.last
render_epp_response 'epp/poll/poll_no_messages' and return unless @message
if @message.attached_obj_type && @message.attached_obj_id
@ -20,7 +20,7 @@ class Epp::PollsController < EppController
end
def ack_poll
@message = current_api_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
@message = current_user.queued_messages.find_by(id: params[:parsed_frame].css('poll').first['msgID'])
unless @message
epp_errors << {

View file

@ -16,7 +16,7 @@ class Epp::SessionsController < EppController
end
def logout
@api_user = current_api_user # cache current_api_user for logging
@api_user = current_user # cache current_user for logging
epp_session[:api_user_id] = nil
response.headers['X-EPP-Returncode'] = '1500'
render_epp_response('logout')