(20250123) Listing permitted from disabled accounts, new activity not allowed.
This commit is contained in:
@@ -416,7 +416,6 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
|
||||
"""
|
||||
This is to simply modify the status of an account to efficiently activate/deactivate it.
|
||||
NOTE: The operation succeeds ONLY IF the new status of the account is different from the existing status.
|
||||
:param sql_conn: The database connection (MariaDB) to use to perform the action.
|
||||
:param mongo_data_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_key: The identifier granted by the 'generate_token_key' method.
|
||||
@@ -428,12 +427,12 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
|
||||
# Fetch the token from the key:
|
||||
additional_filter = additional_filter or {}
|
||||
# additional_filter["status"] = {"$ne": new_status}
|
||||
if self._service_type is not None: additional_filter["serviceType"] = self._service_type
|
||||
if self._client is not None: additional_filter["client"] = self._client
|
||||
auth_token = await self.get_token_from_key(
|
||||
mongo_data_conn = mongo_data_conn,
|
||||
token_key = token_key,
|
||||
must_be_active = False,
|
||||
additional_filter = additional_filter
|
||||
)
|
||||
|
||||
@@ -462,6 +461,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
self,
|
||||
mongo_data_conn: AsyncMongo,
|
||||
token_id: ObjectId | str = None,
|
||||
must_be_active: bool = True,
|
||||
additional_filter: dict = None
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
@@ -469,6 +469,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
To retrieve stored tokens from the database. One token at a time.
|
||||
:param mongo_data_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_id: The identifier of the document that holds the token's details.
|
||||
:param must_be_active: Set this to False if you want to allow pending and disabled accounts to be retrieved.
|
||||
:param additional_filter: Any addition filters to use.
|
||||
:return: The retrieved record that has the token, and information about the service and client if found, else
|
||||
None when there is no matching record.
|
||||
@@ -480,6 +481,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
for k, v in self._base_filter.items(): filter_json[k] = v
|
||||
if additional_filter:
|
||||
for k, v in additional_filter.items(): filter_json[k] = v
|
||||
if must_be_active: filter_json["status"] = "active"
|
||||
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
token = await mongo_data_conn.find_one(
|
||||
@@ -494,6 +496,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
self,
|
||||
mongo_data_conn: AsyncMongo,
|
||||
token_key: ObjectId | str = None,
|
||||
must_be_active: bool = True,
|
||||
additional_filter: dict = None
|
||||
) -> CoreAuthTokenModel | None:
|
||||
|
||||
@@ -501,6 +504,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
To retrieve stored tokens from the database. One token at a time.
|
||||
:param mongo_data_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_key: The identifier granted by the 'generate_token_key' method.
|
||||
:param must_be_active: Set this to False if you want to allow pending and disabled accounts to be retrieved.
|
||||
:param additional_filter: Any addition filters to use.
|
||||
:return: The retrieved record that has the token, and information about the service and client if found, else
|
||||
None when there is no matching record.
|
||||
@@ -512,6 +516,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
for k, v in self._base_filter.items(): filter_json[k] = v
|
||||
if additional_filter:
|
||||
for k, v in additional_filter.items(): filter_json[k] = v
|
||||
if must_be_active: filter_json["status"] = "active"
|
||||
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
token = await mongo_data_conn.find_one(
|
||||
@@ -554,6 +559,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
mongo_data_conn: AsyncMongo,
|
||||
token_ids: List[ObjectId | str] = None,
|
||||
limit: int = 100,
|
||||
must_be_active: bool = True,
|
||||
additional_filter: dict = None
|
||||
) -> List[CoreAuthTokenModel]:
|
||||
|
||||
@@ -562,6 +568,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
:param mongo_data_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_ids: The identifier of the document that holds the token's details.
|
||||
:param limit: The max. no. of records to pick.
|
||||
:param must_be_active: Set this to False if you want to allow pending and disabled accounts to be retrieved.
|
||||
:param additional_filter: Any addition filters to use.
|
||||
:return: The retrieved record that has the token, and information about the service and client if found, else
|
||||
None when there is no matching record.
|
||||
@@ -573,6 +580,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
for k, v in self._base_filter.items(): filter_json[k] = v
|
||||
if additional_filter:
|
||||
for k, v in additional_filter.items(): filter_json[k] = v
|
||||
if must_be_active: filter_json["status"] = "active"
|
||||
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
tokens = await mongo_data_conn.find_many(
|
||||
@@ -589,6 +597,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
mongo_data_conn: AsyncMongo,
|
||||
token_keys: List[ObjectId | str] = None,
|
||||
limit: int = 100,
|
||||
must_be_active: bool = True,
|
||||
additional_filter: dict = None
|
||||
) -> List[CoreAuthTokenModel]:
|
||||
|
||||
@@ -597,6 +606,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
:param mongo_data_conn: The database connection (MongoDB) to use to perform the action.
|
||||
:param token_keys: the identifiers granted by the 'generate_token_key' method.
|
||||
:param limit: The max. no. of records to pick.
|
||||
:param must_be_active: Set this to False if you want to allow pending and disabled accounts to be retrieved.
|
||||
:param additional_filter: Any addition filters to use.
|
||||
:return: The retrieved record that has the token, and information about the service and client if found, else
|
||||
None when there is no matching record.
|
||||
@@ -608,6 +618,7 @@ class CoreAuthTokenController(CoreBaseModel):
|
||||
for k, v in self._base_filter.items(): filter_json[k] = v
|
||||
if additional_filter:
|
||||
for k, v in additional_filter.items(): filter_json[k] = v
|
||||
if must_be_active: filter_json["status"] = "active"
|
||||
|
||||
# If there is some filtering possible, we fetch the token:
|
||||
tokens = await mongo_data_conn.find_many(
|
||||
|
||||
Reference in New Issue
Block a user