Skip to content

Commit

Permalink
Limit api keys to 38 characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
avidal committed Apr 11, 2012
1 parent f292169 commit 6459c4b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wotmad/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ def generate_key(cls):
# the special characters
key = base64.b64encode(key, pair)

# Finally, strip off the trailing == if it exists
# Strip off the trailing == if it exists
key = key.rstrip('==')

# Reduce it down to 38 characters
key = key[:38]

# If this key has been taken already, then try again
if cls.objects.filter(key=key).count():
return cls.generate_key()
Expand Down

0 comments on commit 6459c4b

Please sign in to comment.