Merge branch 'migrate-fabricators-to-factory-bot-factories' into registry-343

This commit is contained in:
Artur Beljajev 2017-11-15 15:46:54 +02:00
commit 411af16f9c
58 changed files with 2505 additions and 432 deletions

View file

@ -2,6 +2,7 @@ module Admin
class ContactsController < BaseController
load_and_authorize_resource
before_action :set_contact, only: [:show]
helper_method :ident_types
def index
params[:q] ||= {}
@ -79,5 +80,9 @@ module Admin
params[:q][:created_at_lteq] = ca_cache
end
def ident_types
Contact::Ident.types
end
end
end

View file

@ -152,9 +152,6 @@ class EppController < ApplicationController
code: '1',
msg: 'handle_errors was executed when there were actually no errors'
}
# rubocop:disable Rails/Output
puts "FULL MESSAGE: #{obj.errors.full_messages} #{obj.errors.inspect}" if Rails.env.test?
# rubocop: enable Rails/Output
end
@errors.uniq!

View file

@ -2,6 +2,7 @@ class Registrar
class ContactsController < DeppController
before_action :init_epp_contact
helper_method :address_processing?
helper_method :ident_types
def index
authorize! :view, Depp::Contact
@ -140,5 +141,9 @@ class Registrar
def address_processing?
Contact.address_processing?
end
def ident_types
Contact::Ident.types
end
end
end

View file

@ -53,7 +53,7 @@ class Registrar
end
def id
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
@user = ApiUser.find_by_idc_data_and_allowed(request.env['SSL_CLIENT_S_DN'], request.ip)
if @user
sign_in(@user, event: :authentication)
@ -87,7 +87,11 @@ class Registrar
return
end
@user = find_user_by_idc(response.user_id_code)
if Setting.registrar_ip_whitelist_enabled
@user = find_user_by_idc_and_allowed(response.user_id_code)
else
@user = find_user_by_idc(response.user_id_code)
end
if @user.persisted?
session[:user_id_code] = response.user_id_code
@ -112,7 +116,7 @@ class Registrar
when 'OUTSTANDING_TRANSACTION'
render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok
when 'USER_AUTHENTICATED'
@user = find_user_by_idc(session[:user_id_code])
@user = find_user_by_idc_and_allowed(session[:user_id_code])
sign_in @user
flash[:notice] = t(:welcome)
flash.keep(:notice)
@ -149,6 +153,18 @@ class Registrar
ApiUser.find_by(identity_code: idc) || User.new
end
def find_user_by_idc_and_allowed(idc)
return User.new unless idc
possible_users = ApiUser.where(identity_code: idc) || User.new
possible_users.each do |selected_user|
if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip)
return selected_user
end
end
end
def check_ip_restriction
ip_restriction = Authorization::RestrictedIP.new(request.ip)
allowed = ip_restriction.can_access_registrar_area_sign_in_page?