Browse Source

Merge pull request #8733 from accumulator/remove_2fa_email

qt, qml: remove email entry from 2FA wallet ToS pages
master
ThomasV 2 years ago committed by GitHub
parent
commit
8199a6b5b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      electrum/gui/qml/components/wizard/WCHaveSeed.qml
  2. 2
      electrum/gui/qt/__init__.py
  3. 4
      electrum/plugins/trustedcoin/common_qt.py
  4. 4
      electrum/plugins/trustedcoin/qml.py
  5. 17
      electrum/plugins/trustedcoin/qml/Terms.qml
  6. 23
      electrum/plugins/trustedcoin/qt.py
  7. 8
      electrum/plugins/trustedcoin/trustedcoin.py

2
electrum/gui/qml/components/wizard/WCHaveSeed.qml

@ -189,7 +189,7 @@ WizardComponent {
InfoTextArea { InfoTextArea {
id: infotext id: infotext
visible: !cosigner visible: !cosigner && !is2fa
Layout.fillWidth: true Layout.fillWidth: true
Layout.columnSpan: 2 Layout.columnSpan: 2
Layout.bottomMargin: constants.paddingLarge Layout.bottomMargin: constants.paddingLarge

2
electrum/gui/qt/__init__.py

@ -458,7 +458,7 @@ class ElectrumGui(BaseElectrumGui, Logger):
'xpub2': db.get('x2')['xpub'], 'xpub2': db.get('x2')['xpub'],
} }
wizard = QENewWalletWizard(self.config, self.app, self.plugins, self.daemon, path, wizard = QENewWalletWizard(self.config, self.app, self.plugins, self.daemon, path,
start_viewstate=WizardViewState('trustedcoin_tos_email', data, {})) start_viewstate=WizardViewState('trustedcoin_tos', data, {}))
result = wizard.exec() result = wizard.exec()
if result == QENewWalletWizard.Rejected: if result == QENewWalletWizard.Rejected:
self.logger.info('wizard dialog cancelled by user') self.logger.info('wizard dialog cancelled by user')

4
electrum/plugins/trustedcoin/common_qt.py

@ -128,7 +128,9 @@ class TrustedcoinPluginQObject(PluginQObject):
t.start() t.start()
@pyqtSlot(str) @pyqtSlot(str)
def createKeystore(self, email): def createKeystore(self):
email = 'dummy@electrum.org'
self.remoteKeyState = '' self.remoteKeyState = ''
self._otpSecret = '' self._otpSecret = ''
self.otpSecretChanged.emit() self.otpSecretChanged.emit()

4
electrum/plugins/trustedcoin/qml.py

@ -15,9 +15,7 @@ if TYPE_CHECKING:
from electrum.wizard import NewWalletWizard from electrum.wizard import NewWalletWizard
class Plugin(TrustedCoinPlugin): class Plugin(TrustedCoinPlugin):
def __init__(self, *args): def __init__(self, *args):
super().__init__(*args) super().__init__(*args)
@ -74,7 +72,7 @@ class Plugin(TrustedCoinPlugin):
'trustedcoin_keep_disable': { 'trustedcoin_keep_disable': {
'gui': '../../../../plugins/trustedcoin/qml/KeepDisable', 'gui': '../../../../plugins/trustedcoin/qml/KeepDisable',
}, },
'trustedcoin_tos_email': { 'trustedcoin_tos': {
'gui': '../../../../plugins/trustedcoin/qml/Terms', 'gui': '../../../../plugins/trustedcoin/qml/Terms',
}, },
'trustedcoin_show_confirm_otp': { 'trustedcoin_show_confirm_otp': {

17
electrum/plugins/trustedcoin/qml/Terms.qml

@ -9,16 +9,11 @@ import "../../../gui/qml/components/controls"
WizardComponent { WizardComponent {
valid: !plugin ? false valid: !plugin ? false
: email.text.length > 0 // TODO: validate email address : tosShown
&& tosShown
property QtObject plugin property QtObject plugin
property bool tosShown: false property bool tosShown: false
onAccept: {
wizard_data['2fa_email'] = email.text
}
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
@ -52,16 +47,6 @@ WizardComponent {
running: visible running: visible
} }
} }
Label {
text: qsTr('Email')
}
TextField {
id: email
Layout.fillWidth: true
placeholderText: qsTr('Enter your email address')
}
} }
Component.onCompleted: { Component.onCompleted: {

23
electrum/plugins/trustedcoin/qt.py

@ -345,7 +345,7 @@ class Plugin(TrustedCoinPlugin):
'gui': WCKeepDisable, 'gui': WCKeepDisable,
'params': {'icon': icon_path('trustedcoin-wizard.png')}, 'params': {'icon': icon_path('trustedcoin-wizard.png')},
}, },
'trustedcoin_tos_email': { 'trustedcoin_tos': {
'gui': WCTerms, 'gui': WCTerms,
'params': {'icon': icon_path('trustedcoin-wizard.png')}, 'params': {'icon': icon_path('trustedcoin-wizard.png')},
}, },
@ -367,12 +367,12 @@ class Plugin(TrustedCoinPlugin):
'next': 'trustedcoin_confirm_seed', 'next': 'trustedcoin_confirm_seed',
}, },
'trustedcoin_confirm_seed': { 'trustedcoin_confirm_seed': {
'next': lambda d: 'trustedcoin_confirm_ext' if wizard.wants_ext(d) else 'trustedcoin_tos_email' 'next': lambda d: 'trustedcoin_confirm_ext' if wizard.wants_ext(d) else 'trustedcoin_tos'
}, },
'trustedcoin_confirm_ext': { 'trustedcoin_confirm_ext': {
'gui': WCConfirmExt, 'gui': WCConfirmExt,
'params': {'icon': icon_path('trustedcoin-wizard.png')}, 'params': {'icon': icon_path('trustedcoin-wizard.png')},
'next': 'trustedcoin_tos_email', 'next': 'trustedcoin_tos',
}, },
'trustedcoin_have_seed': { 'trustedcoin_have_seed': {
'next': lambda d: 'trustedcoin_have_ext' if wizard.wants_ext(d) else 'trustedcoin_keep_disable' 'next': lambda d: 'trustedcoin_have_ext' if wizard.wants_ext(d) else 'trustedcoin_keep_disable'
@ -390,7 +390,7 @@ class Plugin(TrustedCoinPlugin):
'trustedcoin_continue_online': { 'trustedcoin_continue_online': {
'gui': WCContinueOnline, 'gui': WCContinueOnline,
'params': {'icon': icon_path('trustedcoin-wizard.png')}, 'params': {'icon': icon_path('trustedcoin-wizard.png')},
'next': lambda d: 'trustedcoin_tos_email' if d['trustedcoin_go_online'] else 'wallet_password', 'next': lambda d: 'trustedcoin_tos' if d['trustedcoin_go_online'] else 'wallet_password',
'accept': self.on_continue_online, 'accept': self.on_continue_online,
'last': lambda d: not d['trustedcoin_go_online'] and wizard.is_single_password() 'last': lambda d: not d['trustedcoin_go_online'] and wizard.is_single_password()
}, },
@ -460,11 +460,6 @@ class WCTerms(WizardComponent):
self.tos_e.setReadOnly(True) self.tos_e.setReadOnly(True)
self.layout().addWidget(self.tos_e) self.layout().addWidget(self.tos_e)
self.layout().addWidget(QLabel(_("Please enter your e-mail address")))
self.email_e = QLineEdit()
self.email_e.textChanged.connect(self.validate)
self.layout().addWidget(self.email_e)
self.fetch_terms_and_conditions() self.fetch_terms_and_conditions()
def fetch_terms_and_conditions(self): def fetch_terms_and_conditions(self):
@ -479,20 +474,16 @@ class WCTerms(WizardComponent):
def on_terms_retrieved(self, tos: str) -> None: def on_terms_retrieved(self, tos: str) -> None:
self._has_tos = True self._has_tos = True
self.tos_e.setText(tos) self.tos_e.setText(tos)
self.email_e.setFocus(True)
self.validate() self.validate()
def on_terms_error(self, error: str) -> None: def on_terms_error(self, error: str) -> None:
self.error = error self.error = error
def validate(self): def validate(self):
if self._has_tos and self.email_e.text() != '': self.valid = self._has_tos
self.valid = True
else:
self.valid = False
def apply(self): def apply(self):
self.wizard_data['2fa_email'] = self.email_e.text() pass
class WCShowConfirmOTP(WizardComponent): class WCShowConfirmOTP(WizardComponent):
@ -565,7 +556,7 @@ class WCShowConfirmOTP(WizardComponent):
self.wizard.trustedcoin_qhelper.otpError.connect(self.on_otp_error) self.wizard.trustedcoin_qhelper.otpError.connect(self.on_otp_error)
self.wizard.trustedcoin_qhelper.remoteKeyError.connect(self.on_remote_key_error) self.wizard.trustedcoin_qhelper.remoteKeyError.connect(self.on_remote_key_error)
self.wizard.trustedcoin_qhelper.createKeystore(self.wizard_data['2fa_email']) self.wizard.trustedcoin_qhelper.createKeystore()
def update(self): def update(self):
is_new = bool(self.wizard.trustedcoin_qhelper.remoteKeyState != 'wallet_known') is_new = bool(self.wizard.trustedcoin_qhelper.remoteKeyState != 'wallet_known')

8
electrum/plugins/trustedcoin/trustedcoin.py

@ -596,8 +596,6 @@ class TrustedCoinPlugin(BasePlugin):
# insert trustedcoin pages in new wallet wizard # insert trustedcoin pages in new wallet wizard
def extend_wizard(self, wizard: 'NewWalletWizard'): def extend_wizard(self, wizard: 'NewWalletWizard'):
# wizard = self._app.daemon.newWalletWizard
# self.logger.debug(repr(wizard))
views = { views = {
'trustedcoin_start': { 'trustedcoin_start': {
'next': 'trustedcoin_choose_seed', 'next': 'trustedcoin_choose_seed',
@ -610,18 +608,18 @@ class TrustedCoinPlugin(BasePlugin):
'next': 'trustedcoin_confirm_seed' 'next': 'trustedcoin_confirm_seed'
}, },
'trustedcoin_confirm_seed': { 'trustedcoin_confirm_seed': {
'next': 'trustedcoin_tos_email' 'next': 'trustedcoin_tos'
}, },
'trustedcoin_have_seed': { 'trustedcoin_have_seed': {
'next': 'trustedcoin_keep_disable' 'next': 'trustedcoin_keep_disable'
}, },
'trustedcoin_keep_disable': { 'trustedcoin_keep_disable': {
'next': lambda d: 'trustedcoin_tos_email' if d['trustedcoin_keepordisable'] != 'disable' 'next': lambda d: 'trustedcoin_tos' if d['trustedcoin_keepordisable'] != 'disable'
else 'wallet_password', else 'wallet_password',
'accept': self.recovery_disable, 'accept': self.recovery_disable,
'last': lambda d: wizard.is_single_password() and d['trustedcoin_keepordisable'] == 'disable' 'last': lambda d: wizard.is_single_password() and d['trustedcoin_keepordisable'] == 'disable'
}, },
'trustedcoin_tos_email': { 'trustedcoin_tos': {
'next': 'trustedcoin_show_confirm_otp' 'next': 'trustedcoin_show_confirm_otp'
}, },
'trustedcoin_show_confirm_otp': { 'trustedcoin_show_confirm_otp': {

Loading…
Cancel
Save