From f8feeb4fc08bf46abe84a0c945f412d761804a05 Mon Sep 17 00:00:00 2001 From: khushal Date: Tue, 3 Dec 2024 08:30:46 +0530 Subject: [PATCH] (20241203) Testing the new account creation system. We now use a mix of 'entityId', 'billingAccountId', and the actual 'emailId' of the user to identify the unique account. This way one account with TCAOFF can have multiple e-mail ids. --- models/behaviour/mail/oauth_v2.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/models/behaviour/mail/oauth_v2.py b/models/behaviour/mail/oauth_v2.py index 5628776..51b3466 100644 --- a/models/behaviour/mail/oauth_v2.py +++ b/models/behaviour/mail/oauth_v2.py @@ -126,20 +126,22 @@ class MailOAuthModel(BaseModel): # Get the identifier from the database: mongo_json = await mongo_conn.find_one_and_update( collection = MailOAuthModel.AUTH_COLLECTION, - filter = { + filter = mongo_conn.dict_to_dot_notation({ "serviceType": "email", "user": { "entityId": user_info["entityId"], "billingAccountId": user_info["billingAccountId"] }, - "clientUserId": email_id - }, + "clientUserId": { + "email": email_id + } + }), update = { "$set": { "lastRequestTs": request_ts }, "$setOnInsert": { - "version": "1.1.0", + "version": "1.1.1", "serviceType": "email", "client": service_client, "authType": auth_type, @@ -213,10 +215,12 @@ class MailOAuthModel(BaseModel): # Save the token to MongoDB: mongo_json = await mongo_conn.find_one_and_update( collection = MailOAuthModel.AUTH_COLLECTION, - filter = { + filter = mongo_conn.dict_to_dot_notation({ "_id": ObjectId(account_identifier), - "clientUserId": email_id - }, + "clientUserId": { + "email": email_id + } + }), update = { "$set": { "token": token, @@ -288,6 +292,7 @@ class MailOAuthModel(BaseModel): "serviceType": True, "authType": True, "client": True, + "clientUserId": True, "token": True } )