(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.

This commit is contained in:
2024-12-03 08:30:46 +05:30
parent 384d037871
commit f8feeb4fc0
+12 -7
View File
@@ -126,20 +126,22 @@ class MailOAuthModel(BaseModel):
# Get the identifier from the database: # Get the identifier from the database:
mongo_json = await mongo_conn.find_one_and_update( mongo_json = await mongo_conn.find_one_and_update(
collection = MailOAuthModel.AUTH_COLLECTION, collection = MailOAuthModel.AUTH_COLLECTION,
filter = { filter = mongo_conn.dict_to_dot_notation({
"serviceType": "email", "serviceType": "email",
"user": { "user": {
"entityId": user_info["entityId"], "entityId": user_info["entityId"],
"billingAccountId": user_info["billingAccountId"] "billingAccountId": user_info["billingAccountId"]
}, },
"clientUserId": email_id "clientUserId": {
}, "email": email_id
}
}),
update = { update = {
"$set": { "$set": {
"lastRequestTs": request_ts "lastRequestTs": request_ts
}, },
"$setOnInsert": { "$setOnInsert": {
"version": "1.1.0", "version": "1.1.1",
"serviceType": "email", "serviceType": "email",
"client": service_client, "client": service_client,
"authType": auth_type, "authType": auth_type,
@@ -213,10 +215,12 @@ class MailOAuthModel(BaseModel):
# Save the token to MongoDB: # Save the token to MongoDB:
mongo_json = await mongo_conn.find_one_and_update( mongo_json = await mongo_conn.find_one_and_update(
collection = MailOAuthModel.AUTH_COLLECTION, collection = MailOAuthModel.AUTH_COLLECTION,
filter = { filter = mongo_conn.dict_to_dot_notation({
"_id": ObjectId(account_identifier), "_id": ObjectId(account_identifier),
"clientUserId": email_id "clientUserId": {
}, "email": email_id
}
}),
update = { update = {
"$set": { "$set": {
"token": token, "token": token,
@@ -288,6 +292,7 @@ class MailOAuthModel(BaseModel):
"serviceType": True, "serviceType": True,
"authType": True, "authType": True,
"client": True, "client": True,
"clientUserId": True,
"token": True "token": True
} }
) )