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:
parent
fe108d1a35
commit
934bd8dbd9
1 changed files with 13 additions and 0 deletions
|
@ -21,6 +21,19 @@ def account_details(username):
|
||||||
return accounts_db.find_one({'username': 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):
|
def validate_username(username):
|
||||||
allowed_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"
|
allowed_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"
|
||||||
for char in username:
|
for char in username:
|
||||||
|
|
Loading…
Add table
Reference in a new issue