1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

apps.management.change_pin: ask event if unlocked

This commit is contained in:
Jan Pochyla 2016-12-19 11:32:39 +01:00
parent 59feeed3cb
commit 666018ec57

View File

@ -32,24 +32,26 @@ def confirm_remove_pin(session_id):
@unimport @unimport
async def layout_change_pin(session_id, msg): async def layout_change_pin(session_id, msg):
from trezor.messages.Success import Success from trezor.messages.Success import Success
from ..common.request_pin import protect_by_pin, request_pin_twice from apps.common.request_pin import protect_by_pin, request_pin_twice
from ..common import storage from apps.common import storage
if msg.remove: if msg.remove:
if storage.is_protected_by_pin(): if storage.is_protected_by_pin():
await confirm_remove_pin(session_id) await confirm_remove_pin(session_id)
await protect_by_pin(session_id) await protect_by_pin(session_id, at_least_once=True)
storage.load_settings(pin='') pin = ''
return Success(message='PIN removed')
else: else:
if storage.is_protected_by_pin(): if storage.is_protected_by_pin():
await confirm_change_pin(session_id) await confirm_change_pin(session_id)
await protect_by_pin(session_id) await protect_by_pin(session_id, at_least_once=True)
else: else:
await confirm_set_pin(session_id) await confirm_set_pin(session_id)
pin = await request_pin_twice(session_id) pin = await request_pin_twice(session_id)
storage.load_settings(pin=pin)
if pin: storage.load_settings(pin=pin)
storage.lock() if pin:
storage.lock()
return Success(message='PIN changed') return Success(message='PIN changed')
else:
return Success(message='PIN removed')