diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 20ead7a06..b2708c496 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,6 +13,16 @@ class ApplicationController < ActionController::Base return session[:user_return_to].to_s if session[:user_return_to] && session[:user_return_to] != login_path admin_dashboard_path end + + def user_for_paper_trail + if defined?(current_api_user) && current_api_user.present? + "#{current_api_user.id}-api-#{current_api_user.username}" + elsif current_user.present? + "#{current_user.id}-#{current_user.username}" + else + 'public' + end + end end class ApplicationController < ActionController::Base diff --git a/app/controllers/concerns/shared/user_stamper.rb b/app/controllers/concerns/shared/user_stamper.rb index 9dae4105e..98e4e11ab 100644 --- a/app/controllers/concerns/shared/user_stamper.rb +++ b/app/controllers/concerns/shared/user_stamper.rb @@ -1,15 +1,15 @@ module Shared::UserStamper extend ActiveSupport::Concern - def stamp(obj) - return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id) + # def stamp(obj) + # return false if obj.nil? || !obj.has_attribute?(:created_by_id && :updated_by_id) - if obj.new_record? - obj.created_by_id = current_api_user.id - else - obj.updated_by_id = current_api_user.id - end + # if obj.new_record? + # obj.created_by_id = current_api_user.id + # else + # obj.updated_by_id = current_api_user.id + # end - true - end + # true + # end end diff --git a/app/controllers/epp/contacts_controller.rb b/app/controllers/epp/contacts_controller.rb index 45b9d197c..6d2698459 100644 --- a/app/controllers/epp/contacts_controller.rb +++ b/app/controllers/epp/contacts_controller.rb @@ -1,15 +1,10 @@ class Epp::ContactsController < EppController - include Shared::UserStamper ## Refactor this? helper WhodunnitHelper ## Refactor this? - def user_for_paper_trail ## Refactor this? - current_api_user ? "#{current_api_user.id}-ApiUser" : nil - end - def create @contact = Contact.new(contact_and_address_attributes) @contact.registrar = current_api_user.registrar - render_epp_response '/epp/contacts/create' and return if stamp(@contact) && @contact.save + render_epp_response '/epp/contacts/create' and return if @contact.save handle_errors(@contact) end @@ -18,8 +13,8 @@ class Epp::ContactsController < EppController code = params_hash['epp']['command']['update']['update'][:id] @contact = Contact.where(code: code).first - # if update_rights? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update)) - if owner? && stamp(@contact) && @contact.update_attributes(contact_and_address_attributes(:update)) + # 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) diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index e708603ea..2289e8083 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -25,6 +25,11 @@ class EppController < ApplicationController @current_api_user ||= ApiUser.find(epp_session[:api_user_id]) if epp_session[:api_user_id] end + # temp until Martin is ready + def current_api_user + @current_epp_user ||= EppUser.find(epp_session[:epp_user_id]) if epp_session[:epp_user_id] + end + # ERROR + RESPONSE HANDLING def epp_errors @errors ||= [] diff --git a/app/models/contact.rb b/app/models/contact.rb index 636997818..267bfd2be 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -9,9 +9,6 @@ class Contact < ActiveRecord::Base has_many :domains, through: :domain_contacts has_many :statuses, class_name: 'ContactStatus' - # TODO: remove the x_by - belongs_to :created_by, class_name: 'ApiUser', foreign_key: :created_by_id - belongs_to :updated_by, class_name: 'ApiUser', foreign_key: :updated_by_id belongs_to :registrar accepts_nested_attributes_for :address, :disclosure @@ -88,11 +85,11 @@ class Contact < ActiveRecord::Base end def cr_id - created_by ? created_by.username : nil + # created_by ? created_by.username : nil end def up_id - updated_by ? updated_by.username : nil + # updated_by ? updated_by.username : nil end def auth_info_matches(pw)