ThomasV 11 years ago
parent
commit
c11b7b4fbd
  1. 35
      plugins/trustedcoin.py

35
plugins/trustedcoin.py

@ -406,12 +406,19 @@ class Plugin(BasePlugin):
except socket.error:
self.window.show_message('Server not reachable, aborting')
return
except TrustedCoinException as e:
if e.status_code == 409:
r = None
else:
raise e
if r is None:
otp_secret = None
else:
otp_secret = r.get('otp_secret')
if not otp_secret:
self.window.show_message(_('Error'))
return
_xpub3 = r['xpubkey_cosigner']
_id = r['id']
try:
@ -421,7 +428,7 @@ class Plugin(BasePlugin):
self.window.show_message(str(e))
return
if not self.setup_google_auth(self.window, _id, otp_secret):
if not self.setup_google_auth(self.window, self.user_id, otp_secret):
return
self.wallet.add_master_public_key('x3/', xpub3)
@ -670,16 +677,21 @@ class Plugin(BasePlugin):
def setup_google_auth(self, window, _id, otp_secret):
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
vbox = QVBoxLayout()
window.set_layout(vbox)
if otp_secret is not None:
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
vbox.addWidget(QLabel("Please scan this QR code in Google Authenticator."))
qrw = QRCodeWidget(uri)
vbox.addWidget(qrw, 1)
#vbox.addWidget(QLabel(data), 0, Qt.AlignHCenter)
msg = _('Then, enter your Google Authenticator code:')
else:
label = QLabel("This wallet is already registered, but it was never authenticated. To finalize your registration, please enter your Google Authenticator Code. If you do not have this code, delete the wallet file and start a new registration")
label.setWordWrap(1)
vbox.addWidget(label)
msg = _('Google Authenticator code:')
hbox = QHBoxLayout()
msg = _('Then, enter your Google Authenticator code:')
hbox.addWidget(QLabel(msg))
pw = AmountEdit(None, is_int = True)
pw.setFocus(True)
@ -692,14 +704,13 @@ class Plugin(BasePlugin):
vbox.addLayout(Buttons(CancelButton(window), b))
pw.textChanged.connect(lambda: b.setEnabled(len(pw.text())==6))
window.exec_()
while True:
if not window.exec_():
return False
otp = pw.get_amount()
try:
server.auth(_id, otp)
except:
self.window.show_message('Incorrect password, aborting')
return
return True
except:
QMessageBox.information(self.window, _('Message'), _('Incorrect password'), _('OK'))
pw.setText('')

Loading…
Cancel
Save