From fac3721dfd6adff448027d031f9b8c09ef6a8570 Mon Sep 17 00:00:00 2001 From: Ivanq Date: Sat, 26 May 2018 12:15:23 +0300 Subject: [PATCH] Fix signing&publishing file owned by ZeroID/other provider user. Fixes my old PR lol --- plugins/Sidebar/media/Sidebar.coffee | 16 ++++++++++++---- plugins/Sidebar/media/all.js | 24 ++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/plugins/Sidebar/media/Sidebar.coffee b/plugins/Sidebar/media/Sidebar.coffee index bae1f3ed..8ef14b36 100644 --- a/plugins/Sidebar/media/Sidebar.coffee +++ b/plugins/Sidebar/media/Sidebar.coffee @@ -369,12 +369,16 @@ class Sidebar extends Class inner_path = @tag.find("#input-contents").val() @wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (res) => - if @wrapper.site_info.privatekey or @wrapper.site_info.auth_address in res.signers + if @wrapper.site_info.privatekey # Privatekey stored in users.json @wrapper.ws.cmd "siteSign", {privatekey: "stored", inner_path: inner_path, update_changed_files: true}, (res) => if res == "ok" @wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000 - + else if @wrapper.site_info.auth_address in res.signers + # ZeroID or other ID provider + @wrapper.ws.cmd "siteSign", {privatekey: null, inner_path: inner_path, update_changed_files: true}, (res) => + if res == "ok" + @wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000 else # Ask the user for privatekey @wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key @@ -410,12 +414,16 @@ class Sidebar extends Class inner_path = @tag.find("#input-contents").val() @wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (res) => - if @wrapper.site_info.privatekey or @wrapper.site_info.auth_address in res.signers + if @wrapper.site_info.privatekey # Privatekey stored in users.json @wrapper.ws.cmd "sitePublish", {privatekey: "stored", inner_path: inner_path, sign: true}, (res) => if res == "ok" @wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000 - + else if @wrapper.site_info.auth_address in res.signers + # ZeroID or other ID provider + @wrapper.ws.cmd "sitePublish", {privatekey: null, inner_path: inner_path, sign: true}, (res) => + if res == "ok" + @wrapper.notifications.add "sign", "done", "#{inner_path} Signed and published!", 5000 else # Ask the user for privatekey @wrapper.displayPrompt "Enter your private key:", "password", "Sign", "", (privatekey) => # Prompt the private key diff --git a/plugins/Sidebar/media/all.js b/plugins/Sidebar/media/all.js index 0a9e4aaf..99c74791 100644 --- a/plugins/Sidebar/media/all.js +++ b/plugins/Sidebar/media/all.js @@ -716,7 +716,7 @@ window.initScrollable = function () { inner_path: inner_path }, function(res) { var ref; - if (_this.wrapper.site_info.privatekey || (ref = _this.wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0)) { + if (_this.wrapper.site_info.privatekey) { return _this.wrapper.ws.cmd("siteSign", { privatekey: "stored", inner_path: inner_path, @@ -726,6 +726,16 @@ window.initScrollable = function () { return _this.wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000); } }); + } else if (ref = _this.wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0) { + return _this.wrapper.ws.cmd("siteSign", { + privatekey: null, + inner_path: inner_path, + update_changed_files: true + }, function(res) { + if (res === "ok") { + return _this.wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000); + } + }); } else { return _this.wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) { return _this.wrapper.ws.cmd("siteSign", { @@ -784,7 +794,7 @@ window.initScrollable = function () { inner_path: inner_path }, function(res) { var ref; - if (_this.wrapper.site_info.privatekey || (ref = _this.wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0)) { + if (_this.wrapper.site_info.privatekey) { return _this.wrapper.ws.cmd("sitePublish", { privatekey: "stored", inner_path: inner_path, @@ -794,6 +804,16 @@ window.initScrollable = function () { return _this.wrapper.notifications.add("sign", "done", inner_path + " Signed and published!", 5000); } }); + } else if (ref = _this.wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0) { + return _this.wrapper.ws.cmd("sitePublish", { + privatekey: null, + inner_path: inner_path, + sign: true + }, function(res) { + if (res === "ok") { + return _this.wrapper.notifications.add("sign", "done", inner_path + " Signed and published!", 5000); + } + }); } else { return _this.wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) { return _this.wrapper.ws.cmd("sitePublish", {