(20250123) Listing permitted from disabled accounts, new activity not allowed.

This commit is contained in:
2025-01-23 12:54:52 +05:30
parent fe48b79c09
commit 44ff7719f3
14 changed files with 66 additions and 54 deletions
+3 -1
View File
@@ -171,8 +171,10 @@ async def list_chat_messages(
auth_tokens = await current_app.chat_controller.get_tokens_from_keys(
mongo_data_conn = current_app.data_mongo,
token_keys = inbound_data.tokenKeys,
limit = len(inbound_data.tokenKeys)
limit = len(inbound_data.tokenKeys),
must_be_active = False
)
if not auth_tokens: return constants.API_RESPONSE_NO_AUTH_TOKEN
token_ids = [ObjectId(t.authTokenId) for t in auth_tokens]
# Check if these tokens belong to the user claiming ownership:
+3 -6
View File
@@ -217,13 +217,10 @@ async def send_chat_messages_api(
# Get the token from the token key:
auth_token = await current_app.chat_controller.get_token_from_key(
mongo_data_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
)
if auth_token is None: return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
message = f"No such token key."
token_key = inbound_data.tokenKey,
must_be_active = True
)
if not auth_token: return constants.API_RESPONSE_NO_AUTH_TOKEN
# ┏┓ ┓ ┓ ┳┳┓
# ┗┓┏┓┏┓┏┫ ╋┣┓┏┓ ┃┃┃┏┓┏┏┏┓┏┓┏┓
@@ -182,8 +182,10 @@ async def list_mails(
# Get the token ids from the token keys:
auth_tokens = await current_app.mail_controller.get_tokens_from_keys(
mongo_data_conn = current_app.data_mongo,
token_keys = inbound_data.tokenKeys
token_keys = inbound_data.tokenKeys,
must_be_active = False
)
if not auth_tokens: return constants.API_RESPONSE_NO_AUTH_TOKEN
token_ids = [t.authTokenId for t in auth_tokens]
# Build the additional filter:
+5 -11
View File
@@ -222,11 +222,7 @@ async def send_one_mail(
if (
kwargs.get("session_info") is None and
inbound_headers["Remote-IP"] not in current_app.whitelisted_ips
):
return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED
)
): return constants.API_RESPONSE_UNAUTHORIZED
# ┏┓ ┓ • ┏┓┓ ┓
# ┃┃┓┏┏┏┓┏┓┏┓┏┣┓┓┏┓ ┃ ┣┓┏┓┏┃┏
@@ -236,8 +232,10 @@ async def send_one_mail(
# Get the token based on the key:
auth_token = await current_app.mail_controller.get_token_from_key(
mongo_data_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
token_key = inbound_data.tokenKey,
must_be_active = True
)
if not auth_token: return constants.API_RESPONSE_NO_AUTH_TOKEN
# Get the user's info:
if inbound_headers["Remote-IP"] not in current_app.whitelisted_ips:
@@ -249,11 +247,7 @@ async def send_one_mail(
mongo_data_conn = current_app.data_mongo,
user_info = user_info,
token_ids = [auth_token.authTokenId]
): return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
message = "The account does not belong to this user."
)
): return constants.API_RESPONSE_UNAUTHORIZED
# ┏┓ ┓ ┳┳┓ •┓
# ┗┓┏┓┏┓┏┫ ┃┃┃┏┓┓┃
@@ -154,7 +154,9 @@ async def sync_mails(
auth_token = await current_app.mail_controller.get_token_from_key(
mongo_data_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey,
must_be_active = True
)
if not auth_token: return constants.API_RESPONSE_NO_AUTH_TOKEN
# Figure out the client connector:
match auth_token.client:
+5 -6
View File
@@ -157,10 +157,7 @@ async def list_sms_messages(
# If the session token is invalid/expired:
if kwargs.get("session_info") is None:
return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED
)
return constants.API_RESPONSE_UNAUTHORIZED
# ┏┓ ┓ • ┏┓┓ ┓
# ┃┃┓┏┏┏┓┏┓┏┓┏┣┓┓┏┓ ┃ ┣┓┏┓┏┃┏
@@ -171,13 +168,15 @@ async def list_sms_messages(
auth_tokens = await current_app.sms_controller.get_tokens_from_keys(
mongo_data_conn = current_app.data_mongo,
token_keys = inbound_data.tokenKeys,
limit = len(inbound_data.tokenKeys)
limit = len(inbound_data.tokenKeys),
must_be_active = False
)
if not auth_tokens: return constants.API_RESPONSE_NO_AUTH_TOKEN
token_ids = [ObjectId(t.authTokenId) for t in auth_tokens]
# Check if these tokens belong to the user claiming ownership:
if not await token_check.is_authorized(
mongo_conn = current_app.data_mongo,
mongo_data_conn = current_app.data_mongo,
user_info = CoreUserInfoModel(**kwargs["session_info"]),
token_ids = token_ids
): return ResponseModel(
+3 -6
View File
@@ -222,13 +222,10 @@ async def send_sms_messages_api(
# Get the token from the token key:
auth_token = await current_app.sms_controller.get_token_from_key(
mongo_data_conn = current_app.data_mongo,
token_key = inbound_data.tokenKey
)
if auth_token is None: return ResponseModel(
status_code = StatusCodes.FAILED,
http_code = HttpCodes.UNAUTHORIZED,
message = f"No such token key."
token_key = inbound_data.tokenKey,
must_be_active = True
)
if not auth_token: return constants.API_RESPONSE_NO_AUTH_TOKEN
# ┏┓ ┓ ┏┳┓┓ ┏┓┳┳┓┏┓
# ┗┓┏┓┏┓┏┫ ┃ ┣┓┏┓ ┗┓┃┃┃┗┓