mirror of
https://github.com/internetee/registry.git
synced 2025-08-15 05:53:55 +02:00
Story#105842700 - Login user with ID card
This commit is contained in:
parent
6077f6c36d
commit
da910bc660
3 changed files with 15 additions and 14 deletions
|
@ -5,7 +5,7 @@ class Registrant::DomainsController < RegistrantController
|
||||||
authorize! :view, :registrant_domains
|
authorize! :view, :registrant_domains
|
||||||
params[:q] ||= {}
|
params[:q] ||= {}
|
||||||
|
|
||||||
domains = Domain.includes(:registrar, :registrant).where(registrant_id: 76246)
|
domains = current_user.domains
|
||||||
|
|
||||||
normalize_search_parameters do
|
normalize_search_parameters do
|
||||||
@q = domains.search(params[:q])
|
@q = domains.search(params[:q])
|
||||||
|
|
|
@ -2,21 +2,14 @@ class Registrant::SessionsController < Devise::SessionsController
|
||||||
layout 'registrant/application'
|
layout 'registrant/application'
|
||||||
|
|
||||||
def login
|
def login
|
||||||
@user = RegistrantUser.find_by_username('registrar1')
|
|
||||||
sign_in(@user, event: :authentication)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop: disable Metrics/AbcSize
|
# rubocop: disable Metrics/AbcSize
|
||||||
def id
|
def id
|
||||||
if Rails.env.development?
|
id_code, id_issuer = request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O']
|
||||||
sign_in(RegistrantUser.find_or_create_by_idc_data('test'), event: :authentication)
|
id_code, id_issuer = 'test', RegistrantUser::ACCEPTED_ISSUER if Rails.env.development?
|
||||||
return redirect_to registrant_root_url
|
|
||||||
end
|
|
||||||
|
|
||||||
logger.error request.env['SSL_CLIENT_S_DN']
|
@user = RegistrantUser.find_or_create_by_idc_data(id_code, id_issuer)
|
||||||
logger.error request.env['SSL_CLIENT_S_DN'].encoding
|
|
||||||
logger.error request.env['SSL_CLIENT_I_DN_O']
|
|
||||||
@user = RegistrantUser.find_or_create_by_idc_data(request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O'])
|
|
||||||
if @user
|
if @user
|
||||||
sign_in(@user, event: :authentication)
|
sign_in(@user, event: :authentication)
|
||||||
redirect_to registrant_root_url
|
redirect_to registrant_root_url
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
class RegistrantUser < User
|
class RegistrantUser < User
|
||||||
|
ACCEPTED_ISSUER = 'AS Sertifitseerimiskeskus'
|
||||||
attr_accessor :idc_data
|
attr_accessor :idc_data
|
||||||
|
|
||||||
def ability
|
def ability
|
||||||
|
@ -6,6 +7,15 @@ class RegistrantUser < User
|
||||||
end
|
end
|
||||||
delegate :can?, :cannot?, to: :ability
|
delegate :can?, :cannot?, to: :ability
|
||||||
|
|
||||||
|
def ident
|
||||||
|
registrant_ident.to_s.split("-").last
|
||||||
|
end
|
||||||
|
|
||||||
|
def domains
|
||||||
|
Domain.includes(:registrar, :registrant).where(contacts: {ident: ident})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
username
|
username
|
||||||
end
|
end
|
||||||
|
@ -13,11 +23,9 @@ class RegistrantUser < User
|
||||||
class << self
|
class << self
|
||||||
def find_or_create_by_idc_data(idc_data, issuer_organization)
|
def find_or_create_by_idc_data(idc_data, issuer_organization)
|
||||||
return false if idc_data.blank?
|
return false if idc_data.blank?
|
||||||
return false if issuer_organization != 'AS Sertifitseerimiskeskus'
|
return false if issuer_organization != ACCEPTED_ISSUER
|
||||||
|
|
||||||
idc_data.force_encoding('UTF-8')
|
idc_data.force_encoding('UTF-8')
|
||||||
logger.error(idc_data)
|
|
||||||
logger.error(idc_data.encoding)
|
|
||||||
identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first
|
identity_code = idc_data.scan(/serialNumber=(\d+)/).flatten.first
|
||||||
country = idc_data.scan(/^\/C=(.{2})/).flatten.first
|
country = idc_data.scan(/^\/C=(.{2})/).flatten.first
|
||||||
first_name = idc_data.scan(%r{/GN=(.+)/serialNumber}).flatten.first
|
first_name = idc_data.scan(%r{/GN=(.+)/serialNumber}).flatten.first
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue