Created username_for_email(), get_profile(), update_profile()

- username_for_email() to get a username for an acccount, given an email address
- get_profile(username) to get a user profile dict, given a username
- update_profile(username, details) to update a user profile dict, given a username and updated details
This commit is contained in:
Socks 2018-02-16 05:21:58 +00:00
parent fe108d1a35
commit 934bd8dbd9

View file

@ -21,6 +21,19 @@ def account_details(username):
return accounts_db.find_one({'username': username})
def username_for_email(email):
return accounts_db.find_one({'email': email})['username']
def get_profile(username):
return accounts_db.find_one({'username': username})['profile']
def update_profile(username, details):
accounts_db.update_one({'username': username},
{'$set': {'profile': details}})
def validate_username(username):
allowed_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"
for char in username: