Browse Source

otp/email dialog handles pressing enter. do not offer to show seed for 2fa wallet.

3.2.x
SomberNight 7 years ago
committed by ThomasV
parent
commit
248a3a5755
  1. 55
      gui/kivy/uix/dialogs/installwizard.py
  2. 5
      gui/kivy/uix/ui_screens/status.kv

55
gui/kivy/uix/dialogs/installwizard.py

@ -207,6 +207,8 @@ Builder.load_string('''
WizardTextInput:
id: email
on_text: Clock.schedule_once(root.on_text)
multiline: False
on_text_validate: Clock.schedule_once(root.on_enter)
<WizardKnownOTPDialog>
message : ''
@ -224,6 +226,8 @@ Builder.load_string('''
WizardTextInput:
id: otp
on_text: Clock.schedule_once(root.on_text)
multiline: False
on_text_validate: Clock.schedule_once(root.on_enter)
Widget
size_hint: 1, 1
Label:
@ -261,6 +265,8 @@ Builder.load_string('''
WizardTextInput:
id: otp
on_text: Clock.schedule_once(root.on_text)
multiline: False
on_text_validate: Clock.schedule_once(root.on_enter)
<MButton@Button>:
size_hint: 1, None
@ -576,12 +582,8 @@ class WizardMultisigDialog(WizardDialog):
n = self.ids.n.value
return m, n
class WizardKnownOTPDialog(WizardDialog):
def __init__(self, wizard, **kwargs):
WizardDialog.__init__(self, wizard, **kwargs)
self.message = _("This wallet is already registered with TrustedCoin. To finalize wallet creation, please enter your Google Authenticator Code.")
self.message2 =_("If you have lost your Google Authenticator account, check the box below to request a new secret. You will need to retype your seed.")
class WizardOTPDialogBase(WizardDialog):
def get_otp(self):
otp = self.ids.otp.text
@ -592,6 +594,23 @@ class WizardKnownOTPDialog(WizardDialog):
except:
return
def on_text(self, dt):
self.ids.next.disabled = self.get_otp() is None
def on_enter(self, dt):
# press next
next = self.ids.next
if not next.disabled:
next.dispatch('on_release')
class WizardKnownOTPDialog(WizardOTPDialogBase):
def __init__(self, wizard, **kwargs):
WizardOTPDialogBase.__init__(self, wizard, **kwargs)
self.message = _("This wallet is already registered with TrustedCoin. To finalize wallet creation, please enter your Google Authenticator Code.")
self.message2 =_("If you have lost your Google Authenticator account, check the box below to request a new secret. You will need to retype your seed.")
def get_params(self, button):
return (self.get_otp(), self.ids.cb.active)
@ -599,31 +618,17 @@ class WizardKnownOTPDialog(WizardDialog):
self.ids.otp.text = ''
self.ids.next.disabled = not self.ids.cb.active
def on_text(self, dt):
self.ids.next.disabled = self.get_otp() is None
class WizardNewOTPDialog(WizardDialog):
class WizardNewOTPDialog(WizardOTPDialogBase):
def __init__(self, wizard, **kwargs):
WizardDialog.__init__(self, wizard, **kwargs)
WizardOTPDialogBase.__init__(self, wizard, **kwargs)
otp_secret = kwargs['otp_secret']
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
self.message = "Please scan the following QR code in Google Authenticator. You may also use the secret key: %s"%otp_secret
self.message2 = _('Then, enter your Google Authenticator code:')
self.ids.qr.set_data(uri)
def get_otp(self):
otp = self.ids.otp.text
if len(otp) != 6:
return
try:
return int(otp)
except:
return
def on_text(self, dt):
self.ids.next.disabled = self.get_otp() is None
def get_params(self, button):
return (self.get_otp(), False)
@ -637,11 +642,19 @@ class WizardTOSDialog(WizardDialog):
self.message2 = _('Enter your email address:')
class WizardEmailDialog(WizardDialog):
def get_params(self, button):
return (self.ids.email.text,)
def on_text(self, dt):
self.ids.next.disabled = not is_valid_email(self.ids.email.text)
def on_enter(self, dt):
# press next
next = self.ids.next
if not next.disabled:
next.dispatch('on_release')
class WizardConfirmDialog(WizardDialog):
def __init__(self, wizard, **kwargs):

5
gui/kivy/uix/ui_screens/status.kv

@ -4,6 +4,7 @@ Popup:
unconfirmed: 0
unmatured: 0
watching_only: app.wallet.is_watching_only()
has_seed: app.wallet.has_seed()
on_parent:
self.confirmed, self.unconfirmed, self.unmatured = app.wallet.get_balance()
BoxLayout:
@ -70,8 +71,8 @@ Popup:
Button:
size_hint: 0.5, None
height: '48dp'
text: '' if root.watching_only else (_('Hide seed') if seed_label.text else _('Show seed'))
disabled: root.watching_only
text: '' if not root.has_seed else (_('Hide seed') if seed_label.text else _('Show seed'))
disabled: not root.has_seed
on_release:
setattr(seed_label, 'text', '') if seed_label.text else app.show_seed(seed_label)
Button:

Loading…
Cancel
Save