Prompt for password change when using 'jrnl --encrypt' on already encrypted journal (#1477)

* Create new password if journal already encrypted.
* Add test for encrypting already encrypted journal.
This commit is contained in:
Jonathan van der Steege 2022-05-21 23:11:55 +02:00 committed by GitHub
parent 7771afc1a7
commit 663f151974
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View file

@ -17,6 +17,7 @@ from jrnl.exception import JrnlException
from jrnl.messages import Message
from jrnl.messages import MsgText
from jrnl.messages import MsgType
from jrnl.prompt import create_password
def preconfig_diagnostic(_):
@ -84,9 +85,14 @@ def postconfig_encrypt(args, config, original_config, **kwargs):
)
)
journal.config["encrypt"] = True
new_journal = EncryptedJournal.from_journal(journal)
# If journal is encrypted, create new password
if journal.config["encrypt"] is True:
print(f"Journal {journal.name} is already encrypted. Create a new password.")
new_journal.password = create_password(new_journal.name)
journal.config["encrypt"] = True
new_journal.write(args.filename)
print(