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.
pull/387/head
Aidaho 2024-06-07 07:50:49 +03:00
parent 923727b7b7
commit f049daeb3c
1 changed files with 7 additions and 3 deletions

View File

@ -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: