Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/controllers/sign_up/completions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ def track_completion_event(last_page)
end

def pii
pii_string = Pii::Cacher.new(current_user, user_session).fetch_string
JSON.parse(pii_string || '{}', symbolize_names: true)
Pii::Cacher.new(current_user, user_session).fetch || Pii::Attributes.new
end

def send_in_person_completion_survey
Expand Down
16 changes: 2 additions & 14 deletions app/services/pii/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module Pii
# the state in the state id address, which may not be the state that issued the ID
:identity_doc_address_state,
:ssn, :dob, :phone,
*DEPRECATED_PII_ATTRIBUTES
*DEPRECATED_PII_ATTRIBUTES,
keyword_init: true
) do
def self.new_from_hash(hash)
attrs = new
Expand All @@ -32,25 +33,12 @@ def self.new_from_json(pii_json)
new_from_hash(pii)
end

def initialize(*args)
super
assign_all_members
end

def eql?(other)
to_json == other.to_json
end

def ==(other)
eql?(other)
end

private

def assign_all_members
self.class.members.each do |member|
self[member] = self[member]
end
end
end
end
26 changes: 13 additions & 13 deletions app/services/pii/cacher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ def fetch
Pii::Attributes.new_from_json(pii_string)
end

def exists_in_session?
Copy link
Copy Markdown
Contributor Author

@jmhooper jmhooper Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an annoying diff. The actual change was a copy and paste of the fetch_string method.

return user_session[:decrypted_pii] || user_session[:encrypted_pii]
end

def delete
user_session.delete(:decrypted_pii)
user_session.delete(:encrypted_pii)
end

private

attr_reader :user, :user_session

# Between requests, the decrypted PII bundle is encrypted with KMS and moved to the
# 'encrypted_pii' key by the SessionEncryptor.
#
Expand All @@ -47,19 +60,6 @@ def fetch_string
decrypted
end

def exists_in_session?
return user_session[:decrypted_pii] || user_session[:encrypted_pii]
end

def delete
user_session.delete(:decrypted_pii)
user_session.delete(:encrypted_pii)
end

private

attr_reader :user, :user_session

def rotate_fingerprints(profile)
KeyRotator::HmacFingerprinter.new.rotate(
user: user,
Expand Down
4 changes: 2 additions & 2 deletions spec/presenters/completions_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let(:current_user) { create(:user, :fully_registered, identities: identities) }
let(:current_sp) { create(:service_provider, friendly_name: 'Friendly service provider') }
let(:decrypted_pii) do
{
Pii::Attributes.new(
first_name: 'Testy',
last_name: 'Testerson',
ssn: '900123456',
Expand All @@ -24,7 +24,7 @@
zipcode: '20405',
dob: '1990-01-01',
phone: '+12022121000',
}
)
end
let(:requested_attributes) do
[
Expand Down