pin: avoid changing PIN unnecessarily

pull/25/head
Andrew Kozlik 5 years ago committed by Pavol Rusnak
parent 456a2c68d6
commit e60914e30f
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -57,6 +57,8 @@ async def recovery_device(ctx, msg):
# ask for pin repeatedly
if msg.pin_protection:
newpin = await request_pin_confirm(ctx, cancellable=False)
else:
newpin = ""
# dry run
if msg.dry_run:
@ -72,7 +74,7 @@ async def recovery_device(ctx, msg):
)
# save into storage
if msg.pin_protection:
if newpin:
config.change_pin(pin_to_int(""), pin_to_int(newpin))
storage.set_u2f_counter(msg.u2f_counter)
storage.load_settings(label=msg.label, use_passphrase=msg.passphrase_protection)

@ -73,8 +73,9 @@ async def reset_device(ctx, msg):
await show_wrong_entry(ctx)
# write PIN into storage
if not config.change_pin(pin_to_int(""), pin_to_int(newpin)):
raise wire.ProcessError("Could not change PIN")
if newpin:
if not config.change_pin(pin_to_int(""), pin_to_int(newpin)):
raise wire.ProcessError("Could not change PIN")
# write settings and mnemonic into storage
storage.load_settings(label=msg.label, use_passphrase=msg.passphrase_protection)

@ -1 +1 @@
Subproject commit 0e897f673a2150607bae553e21604b253352644e
Subproject commit 511fc205b284605651348512c5c5c2c95a642fa1
Loading…
Cancel
Save