Skip to content

Commit

Permalink
DESENG-463: Fixing Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ratheesh-aot committed Jan 25, 2024
1 parent 8d9c9d4 commit 58d1f33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions met-api/src/met_api/resources/widget_poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def validate_request_format(data):
@cors_preflight('POST')
@API.route('/<int:poll_widget_id>/responses')
class PollResponseRecord(Resource):
"""Resource for recording responses for a poll widget. Not require authentication."""
"""Resource for recording responses for a poll widget. Does not require authentication."""

@staticmethod
@cross_origin(origins=allowedorigins())
Expand Down Expand Up @@ -138,7 +138,7 @@ def is_poll_active(poll_id):

@staticmethod
def is_poll_limit_exceeded(poll_id, participant_id):
"""Check poll limt execeeded or not."""
"""Check poll limit execeeded or not."""
return WidgetPollService.check_already_polled(poll_id, participant_id, 10)

@staticmethod
Expand Down
5 changes: 4 additions & 1 deletion met-api/src/met_api/utils/ip_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def hash_ip(ip_address):
"""
# Retrieve the secret key from Flask configuration with a fallback empty string
secret_key = current_app.config.get('SECRET_KEY', '')

# Extract the fragment (e.g., first three octets of an IPv4 address)
ip_fragment = '.'.join(ip_address.split('.')[:3])

# Concatenate the IP address and secret key, and hash the resulting string
return sha256(f'{ip_address}{secret_key}'.encode()).hexdigest()
return sha256(f'{ip_fragment}{secret_key}'.encode()).hexdigest()

0 comments on commit 58d1f33

Please sign in to comment.