From b3fc3ce915533fcf13dc8c04fc6b2d3ebfe7ec55 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 19 May 2015 11:00:49 +0300 Subject: [PATCH] Use first name and last name in registrant portal --- app/models/registrant_user.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index d73f1eca5..1aa9ff711 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -7,7 +7,7 @@ class RegistrantUser < User delegate :can?, :cannot?, to: :ability def to_s - registrant_ident + username end class << self @@ -15,8 +15,12 @@ class RegistrantUser < User return false if idc_data.blank? identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first country = idc_data.scan(/^\/C=(.{2})/).flatten.first + first_name = idc_data.scan(%r{/GN=(.+)/serialNumber}).flatten.first + last_name = idc_data.scan(%r{/SN=(.+)/GN}).flatten.first - where(registrant_ident: "#{country}-#{identity_code}").first_or_create + u = where(registrant_ident: "#{country}-#{identity_code}").first_or_create + u.username = "#{first_name} #{last_name}" + u.save end end end