diff --git a/main.py b/main.py index 4febdc3..7ce6cbb 100644 --- a/main.py +++ b/main.py @@ -113,8 +113,11 @@ def createChat(): user = usersCollection.find_one({'tokens.token': token}, {"_id":1,"tokens":{"$elemMatch": {"token":token}}}) # If the user exists, continue, otherwise return fail if (user): + # Convert _id to a string, python doesn't like ObjectId() user['_id'] = str(user['_id']) + # Check if the token expiry is after the current date (Using unix timestamp, other mongodb Date datatype is a pain to use in python) if (user['tokens'][0]['expiry'] > int(datetime.now().timestamp())): + # Store the userId userId = user['_id'] print(user) print(user['permissions'])