1
0

trezor pin dialog: only show PIN "strength" when creating/changing

fixes #4832
This commit is contained in:
SomberNight
2020-04-07 18:56:14 +02:00
parent 5259fcb6fd
commit caefea19dd
9 changed files with 35 additions and 22 deletions

View File

@@ -246,6 +246,7 @@ class TrezorClientBase(HardwareClientBase, Logger):
self.handler.show_message(message.format(self.device), self.client.cancel)
def get_pin(self, code=None):
show_strength = True
if code == 2:
msg = _("Enter a new PIN for your {}:")
elif code == 3:
@@ -253,7 +254,8 @@ class TrezorClientBase(HardwareClientBase, Logger):
"NOTE: the positions of the numbers have changed!"))
else:
msg = _("Enter your current {} PIN:")
pin = self.handler.get_pin(msg.format(self.device))
show_strength = False
pin = self.handler.get_pin(msg.format(self.device), show_strength=show_strength)
if not pin:
raise Cancelled
if len(pin) > 9:

View File

@@ -108,7 +108,7 @@ class MatrixDialog(WindowModalDialog):
class QtHandler(QtHandlerBase):
pin_signal = pyqtSignal(object)
pin_signal = pyqtSignal(object, object)
matrix_signal = pyqtSignal(object)
close_matrix_dialog_signal = pyqtSignal()
@@ -121,9 +121,9 @@ class QtHandler(QtHandlerBase):
self.matrix_dialog = None
self.passphrase_on_device = False
def get_pin(self, msg):
def get_pin(self, msg, *, show_strength=True):
self.done.clear()
self.pin_signal.emit(msg)
self.pin_signal.emit(msg, show_strength)
self.done.wait()
return self.response
@@ -144,11 +144,11 @@ class QtHandler(QtHandlerBase):
def close_matrix_dialog(self):
self.close_matrix_dialog_signal.emit()
def pin_dialog(self, msg):
def pin_dialog(self, msg, show_strength):
# Needed e.g. when resetting a device
self.clear_dialog()
dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN"))
matrix = self.pin_matrix_widget_class()
matrix = self.pin_matrix_widget_class(show_strength)
vbox = QVBoxLayout()
vbox.addWidget(QLabel(msg))
vbox.addWidget(matrix)