diff options
author | jelle Spijker <j.spijker@ultimaker.com> | 2021-04-04 13:27:43 +0300 |
---|---|---|
committer | Jelle Spijker <spijker.jelle@gmail.com> | 2021-04-04 13:27:43 +0300 |
commit | 23ba1745a4c0f8b2ba6e52fc03a9d296d09e1584 (patch) | |
tree | 5f4d5c2a513b7cbb554f2dcaa4651d3834bf6e64 /cura/OAuth2/KeyringAttribute.py | |
parent | 279edf7a37f755a56d9237946d068d2d1f4a5a16 (diff) |
Handle storing None values in keyring
Write an empty string as value to the keyring if None is parsed and
return a None value if an empty string was parsed from the keyring.
CURA-7180_keyring_none_value
Diffstat (limited to 'cura/OAuth2/KeyringAttribute.py')
-rw-r--r-- | cura/OAuth2/KeyringAttribute.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cura/OAuth2/KeyringAttribute.py b/cura/OAuth2/KeyringAttribute.py index 76385d6a0b..37781cd889 100644 --- a/cura/OAuth2/KeyringAttribute.py +++ b/cura/OAuth2/KeyringAttribute.py @@ -29,7 +29,8 @@ class KeyringAttribute: def __get__(self, instance: Type["BaseModel"], owner: type) -> str: if self._store_secure: try: - return keyring.get_password("cura", self._keyring_name) + value = keyring.get_password("cura", self._keyring_name) + return value if value != "" else None except NoKeyringError: self._store_secure = False Logger.logException("w", "No keyring backend present") @@ -41,7 +42,7 @@ class KeyringAttribute: if self._store_secure: setattr(instance, self._name, None) try: - keyring.set_password("cura", self._keyring_name, value) + keyring.set_password("cura", self._keyring_name, value if value is not None else "") except PasswordSetError: self._store_secure = False if self._name not in DONT_EVER_STORE_LOCALLY: |