From 92dbe597ea0aec93c5e791b9d4f8368379d477f8 Mon Sep 17 00:00:00 2001 From: ZeroNet Date: Wed, 10 Aug 2016 12:21:34 +0200 Subject: [PATCH] Allow to store extra data in content.json --- src/Ui/UiWebsocket.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Ui/UiWebsocket.py b/src/Ui/UiWebsocket.py index 7765a82f..6adbbef8 100644 --- a/src/Ui/UiWebsocket.py +++ b/src/Ui/UiWebsocket.py @@ -274,21 +274,27 @@ class UiWebsocket(object): self.log.debug("Signing: %s" % inner_path) site = self.site extend = {} # Extended info for signing - if not inner_path.endswith("content.json"): # Find the content.json first - file_info = site.content_manager.getFileInfo(inner_path) + + # Change to the file's content.json + file_info = site.content_manager.getFileInfo(inner_path) + if not inner_path.endswith("content.json"): + if not file_info: + raise Exception("Invalid content.json file: %s" % inner_path) inner_path = file_info["content_inner_path"] - if "cert_signers" in file_info: # Its an user dir file - cert = self.user.getCert(self.site.address) - extend["cert_auth_type"] = cert["auth_type"] - extend["cert_user_id"] = self.user.getCertUserId(site.address) - extend["cert_sign"] = cert["cert_sign"] + + # Add certificate to user files + if file_info and "cert_signers" in file_info and privatekey is None: + cert = self.user.getCert(self.site.address) + extend["cert_auth_type"] = cert["auth_type"] + extend["cert_user_id"] = self.user.getCertUserId(site.address) + extend["cert_sign"] = cert["cert_sign"] if ( not site.settings["own"] and self.user.getAuthAddress(self.site.address) not in self.site.content_manager.getValidSigners(inner_path) ): return self.response(to, {"error": "Forbidden, you can only modify your own sites"}) - if privatekey == "stored": + if privatekey == "stored": # Get privatekey from sites.json privatekey = self.user.getSiteData(self.site.address).get("privatekey") if not privatekey: # Get privatekey from users.json auth_address privatekey = self.user.getAuthPrivatekey(self.site.address)