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