lib/yoti/protobuf/v1/protobuf.rb in yoti-1.0.1 vs lib/yoti/protobuf/v1/protobuf.rb in yoti-1.0.2
- old
+ new
@@ -10,11 +10,12 @@
CT_JPEG = 2 # standard .jpeg image.
CT_DATE = 3 # string in RFC3339 format (YYYY-MM-DD)
CT_PNG = 4 # standard .png image
def current_user(receipt)
- raise ProtobufError, 'The receipt has invalid data.' unless valid_recepit?(receipt)
+ return nil unless valid_receipt?(receipt)
+
profile_content = receipt['other_party_profile_content']
decoded_profile_content = Base64.decode64(profile_content)
V1::Compubapi::EncryptedData.decode(decoded_profile_content)
end
@@ -39,11 +40,13 @@
end
end
private
- def valid_recepit?(receipt)
- receipt.key?('other_party_profile_content') && !receipt['other_party_profile_content'].nil?
+ def valid_receipt?(receipt)
+ receipt.key?('other_party_profile_content') &&
+ !receipt['other_party_profile_content'].nil? &&
+ receipt['other_party_profile_content'] != ''
end
end
end
end