fix #1102
This commit is contained in:
parent
1be26dbf06
commit
c11b7b4fbd
|
@ -406,12 +406,19 @@ class Plugin(BasePlugin):
|
||||||
except socket.error:
|
except socket.error:
|
||||||
self.window.show_message('Server not reachable, aborting')
|
self.window.show_message('Server not reachable, aborting')
|
||||||
return
|
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')
|
otp_secret = r.get('otp_secret')
|
||||||
if not otp_secret:
|
if not otp_secret:
|
||||||
self.window.show_message(_('Error'))
|
self.window.show_message(_('Error'))
|
||||||
return
|
return
|
||||||
|
|
||||||
_xpub3 = r['xpubkey_cosigner']
|
_xpub3 = r['xpubkey_cosigner']
|
||||||
_id = r['id']
|
_id = r['id']
|
||||||
try:
|
try:
|
||||||
|
@ -421,7 +428,7 @@ class Plugin(BasePlugin):
|
||||||
self.window.show_message(str(e))
|
self.window.show_message(str(e))
|
||||||
return
|
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
|
return
|
||||||
|
|
||||||
self.wallet.add_master_public_key('x3/', xpub3)
|
self.wallet.add_master_public_key('x3/', xpub3)
|
||||||
|
@ -670,16 +677,21 @@ class Plugin(BasePlugin):
|
||||||
|
|
||||||
|
|
||||||
def setup_google_auth(self, window, _id, otp_secret):
|
def setup_google_auth(self, window, _id, otp_secret):
|
||||||
uri = "otpauth://totp/%s?secret=%s"%('trustedcoin.com', otp_secret)
|
|
||||||
vbox = QVBoxLayout()
|
vbox = QVBoxLayout()
|
||||||
window.set_layout(vbox)
|
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."))
|
vbox.addWidget(QLabel("Please scan this QR code in Google Authenticator."))
|
||||||
qrw = QRCodeWidget(uri)
|
qrw = QRCodeWidget(uri)
|
||||||
vbox.addWidget(qrw, 1)
|
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()
|
hbox = QHBoxLayout()
|
||||||
msg = _('Then, enter your Google Authenticator code:')
|
|
||||||
hbox.addWidget(QLabel(msg))
|
hbox.addWidget(QLabel(msg))
|
||||||
pw = AmountEdit(None, is_int = True)
|
pw = AmountEdit(None, is_int = True)
|
||||||
pw.setFocus(True)
|
pw.setFocus(True)
|
||||||
|
@ -692,14 +704,13 @@ class Plugin(BasePlugin):
|
||||||
vbox.addLayout(Buttons(CancelButton(window), b))
|
vbox.addLayout(Buttons(CancelButton(window), b))
|
||||||
pw.textChanged.connect(lambda: b.setEnabled(len(pw.text())==6))
|
pw.textChanged.connect(lambda: b.setEnabled(len(pw.text())==6))
|
||||||
|
|
||||||
window.exec_()
|
while True:
|
||||||
|
if not window.exec_():
|
||||||
|
return False
|
||||||
otp = pw.get_amount()
|
otp = pw.get_amount()
|
||||||
try:
|
try:
|
||||||
server.auth(_id, otp)
|
server.auth(_id, otp)
|
||||||
except:
|
|
||||||
self.window.show_message('Incorrect password, aborting')
|
|
||||||
return
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
except:
|
||||||
|
QMessageBox.information(self.window, _('Message'), _('Incorrect password'), _('OK'))
|
||||||
|
pw.setText('')
|
||||||
|
|
Loading…
Reference in New Issue