From 934bd8dbd9ff2fca64251e40fbbcebe40c35d9f0 Mon Sep 17 00:00:00 2001 From: Socks Date: Fri, 16 Feb 2018 05:21:58 +0000 Subject: [PATCH] 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 --- backend/accounts.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/accounts.py b/backend/accounts.py index bce99fc..0835f2d 100644 --- a/backend/accounts.py +++ b/backend/accounts.py @@ -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: