Skip to content

Commit

Permalink
Do not try to fetch profiles if there is no content available
Browse files Browse the repository at this point in the history
  • Loading branch information
Omari Rodney committed Mar 19, 2017
1 parent 5f48d38 commit cb2fe93
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,4 @@ ENV/
# IDE
.idea/
*.un~
.history/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.1.0] - 2017-03-20
### Changed
- Allow empty profiles

## [0.1.2] - 2016-11-23

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions yoti_python_sdk/activity_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@


class ActivityDetails:
def __init__(self, receipt, decrypted_profile):
def __init__(self, receipt, decrypted_profile = None):
self.decrypted_profile = decrypted_profile
self.user_profile = {}

if hasattr(decrypted_profile, 'attributes'):
if decrypted_profile and hasattr(decrypted_profile, 'attributes'):
for field in decrypted_profile.attributes:
value = Protobuf().value_based_on_content_type(
field.value,
Expand Down
3 changes: 3 additions & 0 deletions yoti_python_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def get_activity_details(self, encrypted_request_token):

encrypted_data = protobuf.Protobuf().current_user(receipt)

if not encrypted_data:
return ActivityDetails(receipt)

unwrapped_key = self.__crypto.decrypt_token(receipt['wrapped_receipt_key'])
decrypted_data = self.__crypto.decipher(
unwrapped_key,
Expand Down
5 changes: 3 additions & 2 deletions yoti_python_sdk/protobuf/v1/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class Protobuf(object):
CT_PNG = 4 # standard .png image

def current_user(self, receipt):
if receipt.get('other_party_profile_content') is None:
raise ValueError('The receipt has invalid data')
if receipt.get('other_party_profile_content') is None or receipt.get('other_party_profile_content') == '':
return None

profile_content = receipt['other_party_profile_content']
decoded_profile_content = base64.b64decode(profile_content)

Expand Down

0 comments on commit cb2fe93

Please sign in to comment.