This commit is contained in:
Martin Lensment 2014-06-20 17:37:39 +03:00
parent e20b138644
commit 6d257ecc2c
4 changed files with 24 additions and 14 deletions

View file

@ -0,0 +1,15 @@
module Epp::Common
extend ActiveSupport::Concern
included do
protect_from_forgery with: :null_session
end
def proxy
send(params[:command])
end
def parsed_frame
Nokogiri::XML(params[:frame]).remove_namespaces!
end
end

View file

@ -1,9 +1,6 @@
class Epp::SessionsController < ApplicationController class Epp::SessionsController < ApplicationController
protect_from_forgery with: :null_session include Epp::Common
include Epp::SessionsHelper
def proxy
send(params[:command])
end
private private
def hello def hello
@ -11,11 +8,7 @@ class Epp::SessionsController < ApplicationController
end end
def login def login
login_params = parsed_frame.css('epp command login') @epp_user = EppUser.find_by(login_params)
username = login_params.css('clID').text
password = login_params.css('pw').text
@epp_user = EppUser.find_by(username: username, password: password)
if @epp_user.try(:active) if @epp_user.try(:active)
render 'login_success' render 'login_success'
@ -24,8 +17,4 @@ class Epp::SessionsController < ApplicationController
render 'login_fail' render 'login_fail'
end end
end end
def parsed_frame
Nokogiri::XML(params[:frame]).remove_namespaces!
end
end end

View file

@ -0,0 +1,6 @@
module Epp::SessionsHelper
def login_params
login_params = parsed_frame.css('epp command login')
{ username: login_params.css('clID').text, password: login_params.css('pw').text }
end
end