Skip to content

Commit

Permalink
Merge pull request bread-and-pepper#385 from regisb/master
Browse files Browse the repository at this point in the history
Fix user creation for utf-8 usernames
  • Loading branch information
wunki committed Feb 26, 2014
2 parents bd42445 + e51a3e7 commit 602b39c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion userena/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ def generate_sha1(string, salt=None):
"""
if not isinstance(string, (str, unicode)):
string = str(string)
if isinstance(string, unicode):
string = string.encode("utf-8")
if not salt:
salt = sha_constructor(str(random.random())).hexdigest()[:5]
hash = sha_constructor(salt+str(string.encode('utf-8'))).hexdigest()
hash = sha_constructor(salt+string).hexdigest()

return (salt, hash)

Expand Down

0 comments on commit 602b39c

Please sign in to comment.