From f049daeb3c562ddf9109ea913c4da953902574b8 Mon Sep 17 00:00:00 2001 From: Aidaho Date: Fri, 7 Jun 2024 07:50:49 +0300 Subject: [PATCH] v7.3.0.0: Refactor user and group id retrieval in Roxy-WI module The method `check_user_group_for_flask` has been updated to first check for 'user_uuid' and 'user_group_id' within the given kwargs. If these are not available, it will fall back to retrieve 'uuid' and 'group' from the cookies. This change makes the method more flexible in terms of data source it can utilize, and improves the module's usability when parameters are directly provided. --- app/modules/roxywi/common.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/modules/roxywi/common.py b/app/modules/roxywi/common.py index 3359106d..d5f87195 100644 --- a/app/modules/roxywi/common.py +++ b/app/modules/roxywi/common.py @@ -41,10 +41,14 @@ def get_user_group(**kwargs) -> int: def check_user_group_for_flask(**kwargs) -> bool: if kwargs.get('api_token') is not None: return True - user_uuid = request.cookies.get('uuid') - group_id = request.cookies.get('group') - user_id = user_sql.get_user_id_by_uuid(user_uuid) + if kwargs.get('user_uuid'): + group_id = kwargs.get('user_group_id') + user_uuid = kwargs.get('user_uuid') + else: + user_uuid = request.cookies.get('uuid') + group_id = request.cookies.get('group') + user_id = user_sql.get_user_id_by_uuid(user_uuid) if user_sql.check_user_group(user_id, group_id): return True else: