mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 11:22:04 +00:00
Only use numbers and letters in our API keys.
(imported from commit f845fd092695286b83a2e4c9a5708df778c5b770)
This commit is contained in:
@@ -8,6 +8,7 @@ import base64
|
||||
import hashlib
|
||||
import simplejson
|
||||
import random
|
||||
import string
|
||||
|
||||
# The ordered list of onboarding steps we want new users to complete. If the
|
||||
# steps are changed here, they must also be changed in onboarding.js.
|
||||
@@ -37,8 +38,12 @@ def create_user_profile(realm, email, password, active, bot, full_name, short_na
|
||||
else:
|
||||
user_profile.set_password(password)
|
||||
|
||||
# select 2 random ascii letters or numbers to fill out our base 64 "encoding"
|
||||
randchars = random.choice(string.ascii_letters + string.digits) + \
|
||||
random.choice(string.ascii_letters + string.digits)
|
||||
# Generate a new, random API key
|
||||
user_profile.api_key = base64.b64encode(hashlib.sha256( str(random.getrandbits(256))).digest())[0:32]
|
||||
user_profile.api_key = base64.b64encode(hashlib.sha256(str(random.getrandbits(256))).digest(),
|
||||
randchars)[0:32]
|
||||
return user_profile
|
||||
|
||||
def create_user(email, password, realm, full_name, short_name,
|
||||
|
||||
Reference in New Issue
Block a user