[FIX][16.0]fix change passphrase for non-stored paspphrase

This commit is contained in:
Luc De Meyer 2023-05-28 10:48:17 +02:00
parent 4d0dd78444
commit 3c18c236bc
2 changed files with 11 additions and 3 deletions

View File

@ -213,6 +213,6 @@ You can also find this information in the doc folder of this module (file EBICS_
Known Issues / Roadmap Known Issues / Roadmap
====================== ======================
- add support to import externally generated keys & certificates (currently only 3SKey signature certificate) - add support to import externally generated keys & certificates (currently only 3SKey signature certificate).
- For Odoo 16.0 the interaction with the OCA payment order and bank statement import modules (e.g. french CFONB) is not yet available. - For Odoo 16.0 the interaction with the OCA payment order and bank statement import modules (e.g. french CFONB) is not yet available.

View File

@ -31,16 +31,24 @@ class EbicsChangePassphrase(models.TransientModel):
def change_passphrase(self): def change_passphrase(self):
self.ensure_one() self.ensure_one()
if self.old_pass != self.ebics_userid_id.ebics_passphrase: if (
self.ebics_userid_id.ebics_passphrase_store
and self.old_pass != self.ebics_userid_id.ebics_passphrase
):
raise UserError(_("Incorrect old passphrase.")) raise UserError(_("Incorrect old passphrase."))
if self.new_pass != self.new_pass_check: if self.new_pass != self.new_pass_check:
raise UserError(_("New passphrase verification error.")) raise UserError(_("New passphrase verification error."))
if self.new_pass == self.ebics_userid_id.ebics_passphrase: if self.new_pass == self.ebics_userid_id.ebics_passphrase:
raise UserError(_("New passphrase equal to old passphrase.")) raise UserError(_("New passphrase equal to old passphrase."))
try: try:
passphrase = (
self.ebics_userid_id.ebics_passphrase_store
and self.ebics_userid_id.ebics_passphrase
or self.old_pass
)
keyring = EbicsKeyRing( keyring = EbicsKeyRing(
keys=self.ebics_userid_id.ebics_keys_fn, keys=self.ebics_userid_id.ebics_keys_fn,
passphrase=self.ebics_userid_id.ebics_passphrase, passphrase=passphrase,
) )
keyring.change_passphrase(self.new_pass) keyring.change_passphrase(self.new_pass)
except ValueError as err: except ValueError as err: