mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 17:28:18 +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
|
||||
params[:q] ||= {}
|
||||
|
||||
domains = Domain.includes(:registrar, :registrant).where(registrant_id: 76246)
|
||||
domains = current_user.domains
|
||||
|
||||
normalize_search_parameters do
|
||||
@q = domains.search(params[:q])
|
||||
|
|
|
@ -2,21 +2,14 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
layout 'registrant/application'
|
||||
|
||||
def login
|
||||
@user = RegistrantUser.find_by_username('registrar1')
|
||||
sign_in(@user, event: :authentication)
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def id
|
||||
if Rails.env.development?
|
||||
sign_in(RegistrantUser.find_or_create_by_idc_data('test'), event: :authentication)
|
||||
return redirect_to registrant_root_url
|
||||
end
|
||||
id_code, id_issuer = request.env['SSL_CLIENT_S_DN'], request.env['SSL_CLIENT_I_DN_O']
|
||||
id_code, id_issuer = 'test', RegistrantUser::ACCEPTED_ISSUER if Rails.env.development?
|
||||
|
||||
logger.error request.env['SSL_CLIENT_S_DN']
|
||||
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'])
|
||||
@user = RegistrantUser.find_or_create_by_idc_data(id_code, id_issuer)
|
||||
if @user
|
||||
sign_in(@user, event: :authentication)
|
||||
redirect_to registrant_root_url
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class RegistrantUser < User
|
||||
ACCEPTED_ISSUER = 'AS Sertifitseerimiskeskus'
|
||||
attr_accessor :idc_data
|
||||
|
||||
def ability
|
||||
|
@ -6,6 +7,15 @@ class RegistrantUser < User
|
|||
end
|
||||
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
|
||||
username
|
||||
end
|
||||
|
@ -13,11 +23,9 @@ class RegistrantUser < User
|
|||
class << self
|
||||
def find_or_create_by_idc_data(idc_data, issuer_organization)
|
||||
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')
|
||||
logger.error(idc_data)
|
||||
logger.error(idc_data.encoding)
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue