mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 00:42:04 +02:00
Epp User login
This commit is contained in:
parent
76ec918426
commit
e20b138644
12 changed files with 106 additions and 8 deletions
|
@ -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
3
app/models/epp_user.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class EppUser < ActiveRecord::Base
|
||||
belongs_to :registrar
|
||||
end
|
|
@ -2,4 +2,5 @@ class Registrar < ActiveRecord::Base
|
|||
belongs_to :country
|
||||
has_many :domains
|
||||
has_many :ns_sets
|
||||
has_many :epp_users
|
||||
end
|
||||
|
|
13
app/views/epp/sessions/login_fail.xml.builder
Normal file
13
app/views/epp/sessions/login_fail.xml.builder
Normal 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
|
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue