Ignore empty identity for regisrar user switch #2754

This commit is contained in:
Priit Tark 2015-08-18 14:15:16 +03:00
parent 85e5a17509
commit 598ab7ba63
4 changed files with 32 additions and 11 deletions

View file

@ -40,6 +40,20 @@ class ApiUser < User
self.active = true unless active_changed?
end
class << self
def find_by_idc_data(idc_data)
return false if idc_data.blank?
identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first
find_by(identity_code: identity_code)
end
def all_by_identity_code(identity_code)
ApiUser.where(identity_code: identity_code)
.where("identity_code is NOT NULL and identity_code != ''").includes(:registrar)
end
end
def registrar_typeahead
@registrar_typeahead || registrar || nil
end
@ -75,13 +89,4 @@ class ApiUser < User
md5 = OpenSSL::Digest::MD5.new(cert.to_der).to_s
certificates.api.exists?(md5: md5, common_name: cn)
end
class << self
def find_by_idc_data(idc_data)
return false if idc_data.blank?
identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first
find_by(identity_code: identity_code)
end
end
end