Merge pull request #1439 from imachug/fix-sign-zeroid

Fix signing&publishing file owned by ZeroID/other provider user
This commit is contained in:
ZeroNet 2018-05-28 10:38:26 +02:00 committed by GitHub
commit e9e5c41f79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 6 deletions

View File

@ -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

View File

@ -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", {