mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 05:56:20 +02:00
Added birthday ident verification
This commit is contained in:
parent
34da6f250d
commit
55848e1000
5 changed files with 41 additions and 17 deletions
|
@ -17,7 +17,7 @@ module Eeid
|
|||
return render_invalid_signature unless valid_hmac_signature?(request.headers['X-HMAC-Signature'])
|
||||
|
||||
contact = Contact.find_by_code(permitted_params[:reference])
|
||||
poi = catch_poi
|
||||
poi = catch_poi(contact)
|
||||
verify_contact(contact)
|
||||
inform_registrar(contact, poi)
|
||||
render json: { status: 'success' }, status: :ok
|
||||
|
@ -55,8 +55,8 @@ module Eeid
|
|||
end
|
||||
end
|
||||
|
||||
def catch_poi
|
||||
ident_service = Eeid::IdentificationService.new
|
||||
def catch_poi(contact)
|
||||
ident_service = Eeid::IdentificationService.new(contact.ident_type)
|
||||
response = ident_service.get_proof_of_identity(permitted_params[:identification_request_id])
|
||||
raise StandardError, response[:error] if response[:error].present?
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ module Repp
|
|||
desc 'Get proof of identity pdf file for a contact'
|
||||
def download_poi
|
||||
authorize! :verify, Epp::Contact
|
||||
ident_service = Eeid::IdentificationService.new
|
||||
ident_service = Eeid::IdentificationService.new(@contact.ident_type)
|
||||
response = ident_service.get_proof_of_identity(@contact.verification_id)
|
||||
|
||||
send_data response[:data], filename: "proof_of_identity_#{@contact.verification_id}.pdf",
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
module Actions
|
||||
# The ContactVerify class is responsible for handling the verification process
|
||||
# for a contact, including creating identification requests and updating the
|
||||
# contact's verification status.
|
||||
class ContactVerify
|
||||
attr_reader :contact
|
||||
|
||||
|
@ -7,10 +10,7 @@ module Actions
|
|||
end
|
||||
|
||||
def call
|
||||
if contact.verified_at.present?
|
||||
contact.errors.add(:base, :verification_exists)
|
||||
return
|
||||
end
|
||||
return false unless %w[priv birthday].include? contact.ident_type
|
||||
|
||||
create_identification_request
|
||||
|
||||
|
@ -22,7 +22,7 @@ module Actions
|
|||
private
|
||||
|
||||
def create_identification_request
|
||||
ident_service = Eeid::IdentificationService.new
|
||||
ident_service = Eeid::IdentificationService.new(contact.ident_type)
|
||||
response = ident_service.create_identification_request(request_payload)
|
||||
ContactMailer.identification_requested(contact: contact, link: response['link']).deliver_now
|
||||
rescue Eeid::IdentError => e
|
||||
|
@ -31,6 +31,24 @@ module Actions
|
|||
end
|
||||
|
||||
def request_payload
|
||||
if contact.ident_type == 'birthday'
|
||||
birthday_payload
|
||||
else
|
||||
default_payload
|
||||
end
|
||||
end
|
||||
|
||||
def birthday_payload
|
||||
{
|
||||
claims_required: [
|
||||
{ type: 'birthdate', value: contact.ident },
|
||||
{ type: 'name', value: contact.name }
|
||||
],
|
||||
reference: contact.code
|
||||
}
|
||||
end
|
||||
|
||||
def default_payload
|
||||
{
|
||||
claims_required: [{
|
||||
type: 'sub',
|
||||
|
@ -41,7 +59,11 @@ module Actions
|
|||
end
|
||||
|
||||
def commit
|
||||
@contact.update(ident_request_sent_at: Time.zone.now)
|
||||
@contact.update(
|
||||
ident_request_sent_at: Time.zone.now,
|
||||
verified_at: nil,
|
||||
verification_id: nil
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
module Eeid
|
||||
# This class handles identification services.
|
||||
class IdentificationService < Base
|
||||
CLIENT_ID = ENV['ident_service_client_id']
|
||||
CLIENT_SECRET = ENV['ident_service_client_secret']
|
||||
|
||||
def initialize
|
||||
super(CLIENT_ID, CLIENT_SECRET)
|
||||
def initialize(ident_type = 'priv')
|
||||
super(
|
||||
ENV["#{ident_type}_ident_service_client_id"],
|
||||
ENV["#{ident_type}_ident_service_client_secret"]
|
||||
)
|
||||
end
|
||||
|
||||
def create_identification_request(request_params)
|
||||
|
|
|
@ -261,5 +261,7 @@ whitelist_companies:
|
|||
- '87654321'
|
||||
|
||||
eeid_base_url: 'http://eid.test'
|
||||
ident_service_client_id: 123
|
||||
ident_service_client_secret: 321
|
||||
priv_ident_service_client_id: 123
|
||||
priv_ident_service_client_secret: 321
|
||||
birthday_ident_service_client_id: 456
|
||||
birthday_ident_service_client_secret: 654
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue