Epp User login

This commit is contained in:
Martin Lensment 2014-06-20 17:12:46 +03:00
parent 76ec918426
commit e20b138644
12 changed files with 106 additions and 8 deletions

View file

@ -11,6 +11,21 @@ class Epp::SessionsController < ApplicationController
end
def login
render 'login'
login_params = parsed_frame.css('epp command login')
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)
render 'login_success'
else
response.headers['X-EPP-Returncode'] = '2200'
render 'login_fail'
end
end
def parsed_frame
Nokogiri::XML(params[:frame]).remove_namespaces!
end
end

3
app/models/epp_user.rb Normal file
View file

@ -0,0 +1,3 @@
class EppUser < ActiveRecord::Base
belongs_to :registrar
end

View file

@ -2,4 +2,5 @@ class Registrar < ActiveRecord::Base
belongs_to :country
has_many :domains
has_many :ns_sets
has_many :epp_users
end

View file

@ -0,0 +1,13 @@
xml.instruct!
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
xml.response do
xml.result('code' => '2501') do
xml.msg('Authentication error; server closing connection')
end
end
xml.trID do
xml.svTRID 'svTrid'
xml.clTRID 'wgyn001#10-02-08at13:58:06'
end
end

View file

@ -2,7 +2,7 @@ xml.instruct!
xml.epp('xmlns' => 'urn:ietf:params:xml:ns:epp-1.0', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd') do
xml.response do
xml.result('code' => '1000') do
xml.msg('User test was authenticated. Welcome.', 'lang' => 'en')
xml.msg('Command completed successfully', 'lang' => 'en')
end
end