Skip to content

Commit

Permalink
Fix add hash_ids on robots created before hash_id implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Dec 1, 2023
1 parent 2c1ea02 commit 5eb9ae7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions robosats/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ def __call__(self, request):
try:
if token.user.last_login < timezone.now() - timedelta(minutes=2):
update_last_login(None, token.user)

# START deprecate after v0.6.0
# Add the hash_id to robots created before hash_ids were introduced
if not token.user.robot.hash_id:
token_sha256 = base91_to_hex(token_sha256_b91)
hash = hashlib.sha256(token_sha256.encode("utf-8")).hexdigest()
token.user.robot.hash_id = hash
token.user.robot.save(update_fields=["hash_id"])
# END deprecate after v0.6.0

except Exception:
update_last_login(None, token.user)

Expand Down

0 comments on commit 5eb9ae7

Please sign in to comment.