(20241209) Standardizing the data models for the database. Started with mail authentication.
This commit is contained in:
@@ -71,6 +71,7 @@ from models.data.api.mail.oauth import (
|
||||
OAuthMailAuthorizationRequestHeaders,
|
||||
OAuthMailAuthorizationRequestData
|
||||
)
|
||||
from models.data.core.auth_token import CoreAuthTokenModel
|
||||
|
||||
# For asynchronous activities:
|
||||
import asyncio
|
||||
@@ -169,22 +170,24 @@ async def request_oauth_authorization_url(
|
||||
# Start by assuming failure:
|
||||
auth_url = None
|
||||
|
||||
# ┳ ┓ •┏ ┳┳
|
||||
# ┃┏┫┏┓┏┓╋┓╋┓┏ ┃┃┏┏┓┏┓
|
||||
# ┻┗┻┗ ┛┗┗┗┛┗┫ ┗┛┛┗ ┛
|
||||
# ┛
|
||||
# ┏┓ ┏┳┓ ┓ ┳ ┓
|
||||
# ┃┓┏┓┏┓┏┓┏┓┏┓╋┏┓ ┃ ┏┓┃┏┏┓┏┓ ┃┏┫
|
||||
# ┗┛┗ ┛┗┗ ┛ ┗┻┗┗ ┻ ┗┛┛┗┗ ┛┗ ┻┗┻
|
||||
|
||||
# Make a user identifier from the session info:
|
||||
token_id = await current_app.mail_oauth_model.get_token_id(
|
||||
db_conn = current_app.sql_writer,
|
||||
mongo_conn = current_app.data_mongo,
|
||||
session_token = inbound_headers["X-Session-Token"],
|
||||
user_info = kwargs["session_info"],
|
||||
client_user_id = {"email": inbound_data.mailId},
|
||||
auth = None,
|
||||
service_client = inbound_data.mailClient,
|
||||
auth_type = "oauth",
|
||||
sync_freq = inbound_data.syncFreq
|
||||
auth_token = CoreAuthTokenModel(
|
||||
serviceType = "email",
|
||||
client = inbound_data.mailClient,
|
||||
authType = "oauth",
|
||||
user = kwargs["session_info"],
|
||||
clientUserId = {"email": inbound_data.mailId},
|
||||
status = "pending",
|
||||
syncFreq = inbound_data.syncFreq,
|
||||
),
|
||||
session_token = inbound_headers["X-Session-Token"]
|
||||
)
|
||||
if token_id is None:
|
||||
return ResponseModel(
|
||||
|
||||
Reference in New Issue
Block a user