Fixed error when user fails to enter correct password
Pappy would raise exceptions and continued project in clear-text when the user failed to enter the correct decryption password. Added a boolean status variable to config `crypt_success` that gets set to true when project decrypts correctly, otherwise it is set to false.
This commit is contained in:
parent
6b8861058e
commit
772e7ee507
3 changed files with 8 additions and 3 deletions
|
@ -170,6 +170,7 @@ class PappyConfig(object):
|
|||
self.crypt_dir = 'crypt'
|
||||
self.crypt_file = 'project.crypt'
|
||||
self.crypt_session = False
|
||||
self.crypt_success = False
|
||||
self.salt_file = 'project.salt'
|
||||
|
||||
def get_default_config(self):
|
||||
|
|
|
@ -90,6 +90,7 @@ class Crypto(object):
|
|||
# Quit pappy if user doesn't retry
|
||||
# or if all retries exhuasted
|
||||
if not self.confirm_password_retry() or retries <= 0:
|
||||
self.config.crypt_success = False
|
||||
return False
|
||||
else:
|
||||
self.password = None
|
||||
|
@ -106,6 +107,7 @@ class Crypto(object):
|
|||
self.delete_crypt_files()
|
||||
|
||||
os.chdir(self.config.crypt_dir)
|
||||
self.config.crypt_success = True
|
||||
return True
|
||||
|
||||
def confirm_password_retry(self):
|
||||
|
|
|
@ -72,9 +72,11 @@ class PappySession(object):
|
|||
|
||||
if self.config.crypt_session:
|
||||
self.decrypt()
|
||||
self.config.load_from_file('./config.json')
|
||||
self.config.global_load_from_file()
|
||||
self.delete_data_on_quit = False
|
||||
|
||||
if self.config.crypt_success:
|
||||
self.config.load_from_file('./config.json')
|
||||
self.config.global_load_from_file()
|
||||
self.delete_data_on_quit = False
|
||||
|
||||
# If the data file doesn't exist, create it with restricted permissions
|
||||
if not os.path.isfile(self.config.datafile):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue