qml: explicitly use None when empty string is used as password
backend requires None, Qt5 passes empty string
This commit is contained in:
@@ -171,6 +171,10 @@ class QEDaemon(AuthMixin, QObject):
|
||||
|
||||
self._logger.debug('load wallet ' + str(self._path))
|
||||
|
||||
# map empty string password to None
|
||||
if password == '':
|
||||
password = None
|
||||
|
||||
if not password:
|
||||
password = self._password
|
||||
|
||||
@@ -225,7 +229,7 @@ class QEDaemon(AuthMixin, QObject):
|
||||
wallet = self.daemon._wallets[self._path]
|
||||
self._current_wallet = QEWallet.getInstanceFor(wallet)
|
||||
self.availableWallets.updateWallet(self._path)
|
||||
self._current_wallet.password = password
|
||||
self._current_wallet.password = password if password else None
|
||||
self.walletLoaded.emit(self._name, self._path)
|
||||
|
||||
|
||||
@@ -312,6 +316,9 @@ class QEDaemon(AuthMixin, QObject):
|
||||
@pyqtSlot(str)
|
||||
def setPassword(self, password):
|
||||
assert self._use_single_password
|
||||
# map empty string password to None
|
||||
if password == '':
|
||||
password = None
|
||||
self._logger.debug('about to set password for ALL wallets')
|
||||
self.daemon.update_password_for_directory(old_password=self._password, new_password=password)
|
||||
self._password = password
|
||||
|
||||
@@ -710,14 +710,20 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
|
||||
@pyqtSlot(str)
|
||||
def set_password(self, password):
|
||||
if password == '':
|
||||
password = None
|
||||
|
||||
storage = self.wallet.storage
|
||||
|
||||
# HW wallet not supported yet
|
||||
if storage.is_encrypted_with_hw_device():
|
||||
return
|
||||
|
||||
current_password = self.password if self.password != '' else None
|
||||
|
||||
try:
|
||||
self.wallet.update_password(self.password, password, encrypt_storage=True)
|
||||
self._logger.info(f'PW change from {current_password} to {password}')
|
||||
self.wallet.update_password(current_password, password, encrypt_storage=True)
|
||||
self.password = password
|
||||
except InvalidPassword as e:
|
||||
self._logger.exception(repr(e))
|
||||
|
||||
Reference in New Issue
Block a user