mirror of https://github.com/Aidaho12/haproxy-wi
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
parent
923727b7b7
commit
f049daeb3c
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue