112 lines
4.8 KiB
Python
112 lines
4.8 KiB
Python
"""
|
|
|
|
AUTHOR:
|
|
|
|
Khushal P Soonderji
|
|
|
|
DATE:
|
|
|
|
Wednesday, 27th Nov., 2024
|
|
|
|
OBJECTIVE:
|
|
|
|
To get the session information from the session token for a given user.
|
|
|
|
REFERENCES:
|
|
|
|
N/A
|
|
|
|
DOWNLOADS:
|
|
|
|
N/A
|
|
|
|
"""
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** IMPORT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# To make sibling directories accessible for imports:
|
|
import sys
|
|
sys.path.append(".")
|
|
sys.path.append("..")
|
|
|
|
# To use Quart:
|
|
from quart import current_app
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MACROS / ONE-TIME INIT ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** VARIABLES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** CLASSES ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
# --- Nothing Yet
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** FUNCTIONS ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
async def get_session(session_token):
|
|
|
|
"""
|
|
Gets the session's info from the session token.
|
|
:param session_token: The identifier of the session.
|
|
:return: The info or None.
|
|
"""
|
|
|
|
try:
|
|
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"]
|
|
}
|
|
return session_info
|
|
except Exception as exception:
|
|
return None
|
|
|
|
|
|
# *****************************************************************************************************************
|
|
# ***** ****
|
|
# *** MAIN PROGRAM ***
|
|
# ***** ****
|
|
# *****************************************************************************************************************
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
pass
|