Files
api_utils_converse_v2/api/helpers/user/session.py
T

111 lines
4.5 KiB
Python

"""
AUTHOR:
Khushal P Soonderji
DATE:
Tuesday, 12th 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
# The data models:
from models.data.user import (
IsSessionRequest
)
# *****************************************************************************************************************
# ***** ****
# *** 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.
"""
session_info = await current_app.user.is_session(
db_conn = current_app.sql_reader,
request = IsSessionRequest(sessionToken = session_token),
cache = current_app.module_cache,
)
if isinstance(session_info, dict): return session_info.get("data")
else: return None
# *****************************************************************************************************************
# ***** ****
# *** MAIN PROGRAM ***
# ***** ****
# *****************************************************************************************************************
if __name__ == "__main__":
pass