[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 46a179401a
commit 1e9b3af3a6
2 changed files with 11 additions and 3 deletions

View File

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