From 666018ec57eb58a5d40eef5b6b01ad6281eb6311 Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Mon, 19 Dec 2016 11:32:39 +0100 Subject: [PATCH] apps.management.change_pin: ask event if unlocked --- src/apps/management/change_pin.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/apps/management/change_pin.py b/src/apps/management/change_pin.py index ed4f14c431..cbb03a3618 100644 --- a/src/apps/management/change_pin.py +++ b/src/apps/management/change_pin.py @@ -32,24 +32,26 @@ def confirm_remove_pin(session_id): @unimport async def layout_change_pin(session_id, msg): from trezor.messages.Success import Success - from ..common.request_pin import protect_by_pin, request_pin_twice - from ..common import storage + from apps.common.request_pin import protect_by_pin, request_pin_twice + from apps.common import storage if msg.remove: if storage.is_protected_by_pin(): await confirm_remove_pin(session_id) - await protect_by_pin(session_id) - storage.load_settings(pin='') - return Success(message='PIN removed') + await protect_by_pin(session_id, at_least_once=True) + pin = '' else: if storage.is_protected_by_pin(): await confirm_change_pin(session_id) - await protect_by_pin(session_id) + await protect_by_pin(session_id, at_least_once=True) else: await confirm_set_pin(session_id) pin = await request_pin_twice(session_id) - storage.load_settings(pin=pin) - if pin: - storage.lock() + + storage.load_settings(pin=pin) + if pin: + storage.lock() return Success(message='PIN changed') + else: + return Success(message='PIN removed')