fix(pritunl_user): improve resilience to null or missing user parameters (#10955)

* fix(pritunl_user): improve resilience to null or missing user parameters

* added changelog fragment - 10955

* standardize 10955 changelog fragment content

Co-authored-by: Felix Fontein <felix@fontein.de>

* simplify user params comparison

Co-authored-by: Felix Fontein <felix@fontein.de>

* simplify list fetch

Co-authored-by: Felix Fontein <felix@fontein.de>

* simplify remote value retrieval

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: djenkins <djenkins@twosix.net>
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
David Jenkins
2025-10-29 12:45:29 -04:00
committed by GitHub
parent 7e8e8948a3
commit e84f59a62d
2 changed files with 7 additions and 3 deletions

View File

@@ -208,16 +208,18 @@ def add_or_update_pritunl_user(module):
for key in user_params.keys():
# When a param is not specified grab existing ones to prevent from changing it with the PUT request
if user_params[key] is None:
user_params[key] = users[0][key]
user_params[key] = users[0].get(key)
# 'groups' and 'mac_addresses' are list comparison
if key == "groups" or key == "mac_addresses":
if set(users[0][key]) != set(user_params[key]):
remote_list = users[0].get(key) or []
local_list = user_params[key] or []
if set(remote_list) != set(local_list):
user_params_changed = True
# otherwise it is either a boolean or a string
else:
if users[0][key] != user_params[key]:
if users[0].get(key) != user_params[key]:
user_params_changed = True
# Trigger a PUT on the API to update the current user if settings have changed