Registrar refactor fixes

This commit is contained in:
Priit Tark 2015-04-10 10:58:51 +03:00
parent d09855bc6d
commit 9bb20365c9
15 changed files with 46 additions and 57 deletions

View file

@ -16,23 +16,32 @@ class ApplicationController < ActionController::Base
redirect_to registrar_root_path, alert: exception.message if current_user.is_a?(ApiUser)
end
helper_method :registrar_request?, :admin_request?
def registrar_request?
request.path.match(/^\/registrar/)
end
def admin_request?
request.path.match(/^\/admin/)
end
def after_sign_in_path_for(_resource)
rt = session[:user_return_to].to_s.presence
login_paths = [admin_login_path, registrar_login_path, '/login']
return rt if rt && !login_paths.include?(rt)
if request.path.match('registrar')
registrar_root_path
elsif request.path.match('admin')
admin_root_path
if registrar_request?
registrar_root_url
elsif admin_request?
admin_root_url
end
end
def after_sign_out_path_for(_resource)
if request.path.match('registrar')
registrar_login_path
elsif request.path.match('admin')
admin_login_path
if registrar_request?
registrar_login_url
elsif admin_request?
admin_login_url
end
end

View file

@ -32,7 +32,7 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
def create
authorize! :create, Depp::Contact
@contact = Depp::Contact.new(params[:contact])
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.save
redirect_to registrar_contact_url(@contact.id)
@ -43,9 +43,9 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
def update
authorize! :edit, Depp::Contact
@contact = Depp::Contact.new(params[:contact])
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.update_attributes(params[:contact])
if @contact.update_attributes(params[:depp_contact])
redirect_to registrar_contact_url(@contact.id)
else
render 'edit'
@ -59,7 +59,7 @@ class Registrar::ContactsController < Registrar::DeppController # EPP controller
def destroy
authorize! :delete, Depp::Contact
@contact = Depp::Contact.new(params[:contact])
@contact = Depp::Contact.new(params[:depp_contact])
if @contact.delete
redirect_to registrar_contacts_url, notice: t(:destroyed)

View file

@ -1,11 +1,4 @@
class Registrar::DeppController < RegistrarController # EPP controller
include CurrentUserHelper
include Depp::ApplicationHelper
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :depp_current_user
rescue_from(Errno::ECONNRESET, Errno::ECONNREFUSED) do |_exception|

View file

@ -14,9 +14,9 @@ class Registrar::XmlConsolesController < Registrar::DeppController # EPP control
end
def load_xml
# binding.pry
cl_trid = "#{depp_current_user.tag}-#{Time.now.to_i}"
xml_dir_path = Depp::Engine.root + 'app/views/depp/xml_consoles/epp_requests'
authorize! :create, :registrar_xml_console
cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}"
xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests'
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
render text: xml

View file

@ -2,6 +2,8 @@ class RegistrarController < ApplicationController
before_action :authenticate_user!
layout 'registrar/application'
include Registrar::ApplicationHelper
helper_method :depp_controller?
def depp_controller?
false