Skip to content
Snippets Groups Projects
Commit 3eaf0a82 authored by inso's avatar inso
Browse files

Fix crash when certifying a user we could not find

parent 456dc408
No related branches found
No related tags found
No related merge requests found
...@@ -437,29 +437,32 @@ class Account(QObject): ...@@ -437,29 +437,32 @@ class Account(QObject):
blockid = yield from community.blockid() blockid = yield from community.blockid()
identity = yield from self._identities_registry.future_find(pubkey, community) identity = yield from self._identities_registry.future_find(pubkey, community)
selfcert = yield from identity.selfcert(community) selfcert = yield from identity.selfcert(community)
certification = Certification(PROTOCOL_VERSION, community.currency, if selfcert:
self.pubkey, pubkey, certification = Certification(PROTOCOL_VERSION, community.currency,
blockid.number, blockid.sha_hash, None) self.pubkey, pubkey,
blockid.number, blockid.sha_hash, None)
key = SigningKey(self.salt, password)
certification.sign(selfcert, [key]) key = SigningKey(self.salt, password)
signed_cert = certification.signed_raw(selfcert) certification.sign(selfcert, [key])
logging.debug("Certification : {0}".format(signed_cert)) signed_cert = certification.signed_raw(selfcert)
logging.debug("Certification : {0}".format(signed_cert))
data = {'pubkey': pubkey,
'self_': selfcert.signed_raw(), data = {'pubkey': pubkey,
'other': "{0}\n".format(certification.inline())} 'self_': selfcert.signed_raw(),
logging.debug("Posted data : {0}".format(data)) 'other': "{0}\n".format(certification.inline())}
responses = yield from community.bma_access.broadcast(bma.wot.Add, {}, data) logging.debug("Posted data : {0}".format(data))
result = (False, "") responses = yield from community.bma_access.broadcast(bma.wot.Add, {}, data)
for r in responses: result = (False, "")
if r.status == 200: for r in responses:
result = (True, (yield from r.json())) if r.status == 200:
elif not result[0]: result = (True, (yield from r.json()))
result = (False, (yield from r.text())) elif not result[0]:
else: result = (False, (yield from r.text()))
yield from r.release() else:
return result yield from r.release()
return result
else:
return (False, self.tr("Could not find user self certification."))
@asyncio.coroutine @asyncio.coroutine
def revoke(self, password, community): def revoke(self, password, community):
......
...@@ -114,4 +114,4 @@ class CertificationDialog(QDialog, Ui_CertificationDialog): ...@@ -114,4 +114,4 @@ class CertificationDialog(QDialog, Ui_CertificationDialog):
future = asyncio.Future() future = asyncio.Future()
self.finished.connect(lambda r: future.set_result(r)) self.finished.connect(lambda r: future.set_result(r))
self.open() self.open()
return future return future
\ No newline at end of file
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