[IMP]account_ebics UI improvements

This commit is contained in:
Luc De Meyer 2024-01-21 22:36:00 +01:00
parent cb838145c2
commit 90d5b369d6

View File

@ -284,20 +284,27 @@ class EbicsUserID(models.Model):
if self.signature_class == "T":
self.swift_3skey = False
@api.onchange("ebics_passphrase_store")
@api.onchange("ebics_passphrase_store", "ebics_passphrase")
def _onchange_ebics_passphrase_store(self):
if self.ebics_passphrase_store:
if self.ebics_passphrase:
# check passphrase before db store
keyring_params = {
"keys": self.ebics_keys_fn,
"passphrase": self.ebics_passphrase,
}
keyring = EbicsKeyRing(**keyring_params)
try:
# TODO: implement check passphrase logic
keyring = EbicsKeyRing(**keyring_params) # noqa: F841
except Exception as err:
raise UserError(str(err)) from err
elif not self.ebics_passphrase_store and self.state != "draft":
# fintech <= 7.4.3 does not have a call to check if a
# passphrase matches with the value stored in the keyfile.
# We get around this limitation as follows:
# Get user keys to check for valid passphrases
# It will raise a ValueError on invalid passphrases
keyring["#USER"]
except ValueError as err: # noqa: F841
raise UserError(_("Passphrase mismatch.")) # noqa: B904
else:
if self.state != "draft":
self.ebics_passphrase = False
@api.onchange("swift_3skey")