mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 19:48:31 +02:00
update encrypted journal prompt to use new messaging functionality
This commit is contained in:
parent
ebfc7bd965
commit
71eb7462be
2 changed files with 7 additions and 3 deletions
|
@ -1,5 +1,4 @@
|
||||||
import base64
|
import base64
|
||||||
import getpass
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -46,8 +45,12 @@ def decrypt_content(
|
||||||
keychain: str = None,
|
keychain: str = None,
|
||||||
max_attempts: int = 3,
|
max_attempts: int = 3,
|
||||||
) -> str:
|
) -> str:
|
||||||
|
get_pw = lambda: print_msg(
|
||||||
|
Message(MsgText.Password, MsgStyle.PROMPT), get_input=True, hide_input=True
|
||||||
|
)
|
||||||
|
|
||||||
pwd_from_keychain = keychain and get_keychain(keychain)
|
pwd_from_keychain = keychain and get_keychain(keychain)
|
||||||
password = pwd_from_keychain or getpass.getpass()
|
password = pwd_from_keychain or get_pw()
|
||||||
result = decrypt_func(password)
|
result = decrypt_func(password)
|
||||||
# Password is bad:
|
# Password is bad:
|
||||||
if result is None and pwd_from_keychain:
|
if result is None and pwd_from_keychain:
|
||||||
|
@ -55,7 +58,7 @@ def decrypt_content(
|
||||||
attempt = 1
|
attempt = 1
|
||||||
while result is None and attempt < max_attempts:
|
while result is None and attempt < max_attempts:
|
||||||
print_msg(Message(MsgText.WrongPasswordTryAgain, MsgStyle.WARNING))
|
print_msg(Message(MsgText.WrongPasswordTryAgain, MsgStyle.WARNING))
|
||||||
password = getpass.getpass()
|
password = get_pw()
|
||||||
result = decrypt_func(password)
|
result = decrypt_func(password)
|
||||||
attempt += 1
|
attempt += 1
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,7 @@ class MsgText(Enum):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# --- Password --- #
|
# --- Password --- #
|
||||||
|
Password = "Password:"
|
||||||
PasswordFirstEntry = "Enter new password: "
|
PasswordFirstEntry = "Enter new password: "
|
||||||
PasswordConfirmEntry = "Enter password again: "
|
PasswordConfirmEntry = "Enter password again: "
|
||||||
PasswordMaxTriesExceeded = "Too many attempts with wrong password"
|
PasswordMaxTriesExceeded = "Too many attempts with wrong password"
|
||||||
|
|
Loading…
Add table
Reference in a new issue