(20241209) Standardizing the data models for the database. Started with mail authentication.
This commit is contained in:
@@ -37,6 +37,9 @@ sys.path.append("..")
|
||||
# To use Quart:
|
||||
from quart import current_app
|
||||
|
||||
# The data model:
|
||||
from models.data.core.user_info import CoreUserInfoModel
|
||||
|
||||
|
||||
# *****************************************************************************************************************
|
||||
# ***** ****
|
||||
@@ -84,18 +87,27 @@ async def get_session(session_token):
|
||||
"""
|
||||
|
||||
try:
|
||||
|
||||
# Fetch the raw info from cache:
|
||||
raw_info = await current_app.module_cache.get(key = session_token)
|
||||
session_info = {
|
||||
"fullName": raw_info["value"]["full_name"],
|
||||
"userId": raw_info["value"]["user_id"],
|
||||
"entityId": raw_info["value"]["entity_id"],
|
||||
"billingAccountId": raw_info["value"]["billing_account_id"],
|
||||
"departmentId": raw_info["value"]["department_id"],
|
||||
"branchId": raw_info["value"]["branch_id"],
|
||||
"industry": raw_info["value"]["industry"]
|
||||
}
|
||||
|
||||
# Feed needed field into the core model:
|
||||
session_info = CoreUserInfoModel(
|
||||
fullName = raw_info["value"]["full_name"],
|
||||
userId = raw_info["value"]["user_id"],
|
||||
entityId = raw_info["value"]["entity_id"],
|
||||
billingAccountId = raw_info["value"]["billing_account_id"],
|
||||
departmentId = raw_info["value"]["department_id"],
|
||||
branchId = raw_info["value"]["branch_id"],
|
||||
industry = raw_info["value"]["industry"]
|
||||
)
|
||||
|
||||
# Done here:
|
||||
return session_info
|
||||
|
||||
# In case something goes wrong:
|
||||
except Exception as exception:
|
||||
current_app.printer(exception)
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user