From 07de336586b3211e75ca28c1a15d1ba6caafd63a Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Tue, 25 Jun 2019 13:23:36 +0200 Subject: [PATCH] core/pin: do not allow empty pin --- core/src/trezor/ui/pin.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/trezor/ui/pin.py b/core/src/trezor/ui/pin.py index 06284d28f..ac4b472d3 100644 --- a/core/src/trezor/ui/pin.py +++ b/core/src/trezor/ui/pin.py @@ -85,6 +85,7 @@ class PinDialog(ui.Layout): icon_confirm = res.load(ui.ICON_CONFIRM) self.confirm_button = Button(ui.grid(14), icon_confirm, ButtonConfirm) self.confirm_button.on_click = self.on_confirm + self.confirm_button.disable() icon_back = res.load(ui.ICON_BACK) self.reset_button = Button(ui.grid(12), icon_back, ButtonClear) @@ -103,14 +104,14 @@ class PinDialog(ui.Layout): ] def dispatch(self, event, x, y): - for btn in self.pin_buttons: - btn.dispatch(event, x, y) self.input.dispatch(event, x, y) - self.confirm_button.dispatch(event, x, y) if self.input.pin: self.reset_button.dispatch(event, x, y) else: self.cancel_button.dispatch(event, x, y) + self.confirm_button.dispatch(event, x, y) + for btn in self.pin_buttons: + btn.dispatch(event, x, y) def assign(self, pin): if len(pin) > self.maxlength: @@ -121,9 +122,11 @@ class PinDialog(ui.Layout): else: btn.disable() if pin: + self.confirm_button.enable() self.reset_button.enable() self.cancel_button.disable() else: + self.confirm_button.disable() self.reset_button.disable() self.cancel_button.enable() self.input.pin = pin @@ -136,4 +139,5 @@ class PinDialog(ui.Layout): raise ui.Result(CANCELLED) def on_confirm(self): - raise ui.Result(self.input.pin) + if self.input.pin: + raise ui.Result(self.input.pin)