[IMP]account_ebics UI improvements

This commit is contained in:
Luc De Meyer 2024-01-21 22:36:00 +01:00
parent 604ce31ae1
commit f2a9af0deb

View File

@ -284,21 +284,28 @@ class EbicsUserID(models.Model):
if self.signature_class == "T": if self.signature_class == "T":
self.swift_3skey = False self.swift_3skey = False
@api.onchange("ebics_passphrase_store") @api.onchange("ebics_passphrase_store", "ebics_passphrase")
def _onchange_ebics_passphrase_store(self): def _onchange_ebics_passphrase_store(self):
if self.ebics_passphrase_store: if self.ebics_passphrase_store:
# check passphrase before db store if self.ebics_passphrase:
keyring_params = { # check passphrase before db store
"keys": self.ebics_keys_fn, keyring_params = {
"passphrase": self.ebics_passphrase, "keys": self.ebics_keys_fn,
} "passphrase": self.ebics_passphrase,
try: }
# TODO: implement check passphrase logic keyring = EbicsKeyRing(**keyring_params)
keyring = EbicsKeyRing(**keyring_params) # noqa: F841 try:
except Exception as err: # fintech <= 7.4.3 does not have a call to check if a
raise UserError(str(err)) from err # passphrase matches with the value stored in the keyfile.
elif not self.ebics_passphrase_store and self.state != "draft": # We get around this limitation as follows:
self.ebics_passphrase = False # 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") @api.onchange("swift_3skey")
def _onchange_swift_3skey(self): def _onchange_swift_3skey(self):