(20241214) testing token keys instead of direct ids.
This commit is contained in:
@@ -156,17 +156,44 @@ async def get_one_mail(
|
||||
:return: A standard response structure.
|
||||
"""
|
||||
|
||||
# ┏┓ ┓ ┏┓┓ ┓
|
||||
# ┣┫┓┏╋┣┓ ┃ ┣┓┏┓┏┃┏
|
||||
# ┛┗┗┻┗┛┗ ┗┛┛┗┗ ┗┛┗
|
||||
|
||||
# If the session token is invalid/expired:
|
||||
if kwargs.get("session_info") is None:
|
||||
return ResponseModel(
|
||||
status_code = StatusCodes.FAILED,
|
||||
http_code = HttpCodes.UNAUTHORIZED
|
||||
http_code = HttpCodes.UNAUTHORIZED,
|
||||
messge = "invalid session"
|
||||
)
|
||||
|
||||
# ┏┓ ┓ ┏┳┓ ┓
|
||||
# ┣ ┏┓╋┏┣┓ ┃ ┏┓┃┏┏┓┏┓┏
|
||||
# ┻ ┗ ┗┗┛┗ ┻ ┗┛┛┗┗ ┛┗┛
|
||||
|
||||
# We first load the authorization tokens:
|
||||
auth_token = await current_app.mail_controller.get_token(
|
||||
mongo_conn = current_app.data_mongo,
|
||||
token_key = inbound_data.tokenKey,
|
||||
)
|
||||
|
||||
# If we failed to load the authorization tokens:
|
||||
if not auth_token:
|
||||
return ResponseModel(
|
||||
status_code = StatusCodes.FAILED,
|
||||
http_code = HttpCodes.UNAUTHORIZED,
|
||||
message = f"no such token key '{inbound_data.tokenKey}'"
|
||||
)
|
||||
|
||||
# ┏┓ ┓ ┳┳┓ •┓
|
||||
# ┣ ┏┓╋┏┣┓ ┃┃┃┏┓┓┃
|
||||
# ┻ ┗ ┗┗┛┗ ┛ ┗┗┻┗┗
|
||||
|
||||
# Get the mail:
|
||||
message = await current_app.mail_controller.get_one_mail(
|
||||
mongo_conn = current_app.data_mongo,
|
||||
token_id = inbound_data.tokenId,
|
||||
token_id = auth_token.authTokenId,
|
||||
message_id = inbound_data.messageId
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user