(20241228) Payments module revamped!

This commit is contained in:
2024-12-28 16:34:57 +05:30
parent 7ddae1707f
commit 5c17eb28ae
18 changed files with 1477 additions and 156 deletions
+6 -6
View File
@@ -88,14 +88,14 @@ from models.core.user import CoreUserInfoModel
async def is_authorized(
mongo_conn: AsyncMongo,
mongo_data_conn: AsyncMongo,
user_info: CoreUserInfoModel | dict,
token_ids: ObjectId | str | List[ObjectId | str]
) -> bool:
"""
To verify if the token id is owned by the user (who will be initially identified from his session token).
:param mongo_conn: The instance of the MongoDB connector to use to perform this action.
:param mongo_data_conn: The instance of the MongoDB connector to use to perform this action.
:param user_info: The user trying to access some service.
:param token_ids: One or more token ids that the user is claiming to own.
:return: True if the user is authorized to use this token, else False.
@@ -113,7 +113,7 @@ async def is_authorized(
# Fetch the auth tokens from the database:
# Retrieve the document of the token id:
auth_tokens = await current_app.core_auth_token_controller.get_tokens_from_ids(
mongo_data_conn = mongo_conn,
mongo_data_conn = mongo_data_conn,
token_ids = [ObjectId(t) for t in token_ids]
)
@@ -131,21 +131,21 @@ async def is_authorized(
async def is_not_authorized(
mongo_conn: AsyncMongo,
mongo_data_conn: AsyncMongo,
user_info: CoreUserInfoModel,
token_ids: ObjectId | str | List[ObjectId | str]
) -> bool:
"""
Just a wrapper around the above function to improve readability.
:param mongo_conn: The instance of the MongoDB connector to use to perform this action.
:param mongo_data_conn: The instance of the MongoDB connector to use to perform this action.
:param user_info: The user trying to access some service.
:param token_ids: One or more token ids that the user is claiming to own.
:return: True if the user is authorized to use this token, else False.
"""
authorized = await is_authorized(
mongo_conn = mongo_conn,
mongo_data_conn = mongo_data_conn,
user_info = user_info,
token_ids = token_ids
)