Skip to content
Snippets Groups Projects
Commit 4ca242f8 authored by inso's avatar inso
Browse files

Fixing key publishing & membership asking

parent a71fd3e0
No related branches found
No related tags found
No related merge requests found
...@@ -96,18 +96,10 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): ...@@ -96,18 +96,10 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
dialog.exec_() dialog.exec_()
def send_membership_demand(self): def send_membership_demand(self):
password = "" password = self.password_asker.ask()
message = "Please enter your password" if password == "":
return
while not self.account.check_password(password):
password = QInputDialog.getText(self, "Account password",
message,
QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True:
password = password[0]
else:
return
try: try:
self.account.send_membership(password, self.community, 'IN') self.account.send_membership(password, self.community, 'IN')
except ValueError as e: except ValueError as e:
...@@ -119,18 +111,10 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget): ...@@ -119,18 +111,10 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
You can't request a membership.") You can't request a membership.")
def send_membership_leaving(self): def send_membership_leaving(self):
password = "" password = self.password_asker.ask()
message = "Please enter your password" if password == "":
return
while not self.account.check_password(password):
password = QInputDialog.getText(self, "Account password",
message,
QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True:
password = password[0]
else:
return
try: try:
self.account.send_membership(password, self.community, 'OUT') self.account.send_membership(password, self.community, 'OUT')
except ValueError as e: except ValueError as e:
......
...@@ -6,10 +6,11 @@ Created on 6 mars 2014 ...@@ -6,10 +6,11 @@ Created on 6 mars 2014
import logging import logging
from ucoinpy.documents.peer import Peer from ucoinpy.documents.peer import Peer
from ucoinpy.key import SigningKey from ucoinpy.key import SigningKey
from cutecoin.gen_resources.account_cfg_uic import Ui_AccountConfigurationDialog from ..gen_resources.account_cfg_uic import Ui_AccountConfigurationDialog
from cutecoin.gui.process_cfg_community import ProcessConfigureCommunity from ..gui.process_cfg_community import ProcessConfigureCommunity
from cutecoin.models.communities import CommunitiesListModel from ..gui.password_asker import PasswordAskerDialog
from cutecoin.tools.exceptions import KeyAlreadyUsed, Error from ..models.communities import CommunitiesListModel
from ..tools.exceptions import KeyAlreadyUsed, Error
from PyQt5.QtWidgets import QDialog, QErrorMessage, QInputDialog, QMessageBox, QLineEdit from PyQt5.QtWidgets import QDialog, QErrorMessage, QInputDialog, QMessageBox, QLineEdit
...@@ -84,6 +85,7 @@ class StepPageKey(Step): ...@@ -84,6 +85,7 @@ class StepPageKey(Step):
password = self.config_dialog.edit_password.text() password = self.config_dialog.edit_password.text()
self.config_dialog.account.salt = salt self.config_dialog.account.salt = salt
self.config_dialog.account.pubkey = SigningKey(salt, password).pubkey self.config_dialog.account.pubkey = SigningKey(salt, password).pubkey
self.config_dialog.password_asker = PasswordAskerDialog(self.config_dialog.account)
model = CommunitiesListModel(self.config_dialog.account) model = CommunitiesListModel(self.config_dialog.account)
self.config_dialog.list_communities.setModel(model) self.config_dialog.list_communities.setModel(model)
...@@ -135,6 +137,7 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog): ...@@ -135,6 +137,7 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog):
super().__init__() super().__init__()
self.setupUi(self) self.setupUi(self)
self.account = account self.account = account
self.password_asker = None
self.app = app self.app = app
step_init = StepPageInit(self) step_init = StepPageInit(self)
step_key = StepPageKey(self) step_key = StepPageKey(self)
...@@ -153,7 +156,9 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog): ...@@ -153,7 +156,9 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog):
def open_process_add_community(self): def open_process_add_community(self):
logging.debug("Opening configure community dialog") logging.debug("Opening configure community dialog")
dialog = ProcessConfigureCommunity(self.account, None) logging.debug(self.password_asker)
dialog = ProcessConfigureCommunity(self.account, None,
self.password_asker)
dialog.accepted.connect(self.action_add_community) dialog.accepted.connect(self.action_add_community)
dialog.exec_() dialog.exec_()
...@@ -229,17 +234,10 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog): ...@@ -229,17 +234,10 @@ class ProcessConfigureAccount(QDialog, Ui_AccountConfigurationDialog):
QErrorMessage(self).showMessage(e.message) QErrorMessage(self).showMessage(e.message)
password = self.edit_password.text() password = self.edit_password.text()
else: else:
message = "Please enter your password" password = self.password_asker.ask()
if password == "":
while not self.account.check_password(password): return
password = QInputDialog.getText(self, "Account password",
message,
QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True:
password = password[0]
else:
return
nb_wallets = self.spinbox_wallets.value() nb_wallets = self.spinbox_wallets.value()
self.account.set_walletpool_size(nb_wallets, password) self.account.set_walletpool_size(nb_wallets, password)
self.app.save(self.account) self.app.save(self.account)
......
...@@ -88,7 +88,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -88,7 +88,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
Dialog to configure or add a community Dialog to configure or add a community
''' '''
def __init__(self, account, community, default_node=None): def __init__(self, account, community, password_asker, default_node=None):
''' '''
Constructor Constructor
''' '''
...@@ -96,6 +96,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -96,6 +96,7 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
self.setupUi(self) self.setupUi(self)
self.community = community self.community = community
self.account = account self.account = account
self.password_asker = password_asker
self.step = None self.step = None
self.peers = [] self.peers = []
...@@ -168,18 +169,9 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog): ...@@ -168,18 +169,9 @@ class ProcessConfigureCommunity(QDialog, Ui_CommunityConfigurationDialog):
{0}\n \ {0}\n \
Would you like to publish the key ?".format(self.account.pubkey)) Would you like to publish the key ?".format(self.account.pubkey))
if reply == QMessageBox.Yes: if reply == QMessageBox.Yes:
password = "" password = self.password_asker.ask()
message = "Please enter your password" if password == "":
return
while not self.account.check_password(password):
password = QInputDialog.getText(self, "Account password",
message,
QLineEdit.Password)
message = "Error, wrong password. Please enter your password"
if password[1] is True:
password = password[0]
else:
return
try: try:
self.account.send_pubkey(password, self.community) self.account.send_pubkey(password, self.community)
except ValueError as e: except ValueError as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment