mirror of
https://github.com/HelloZeroNet/ZeroNet.git
synced 2023-12-14 04:33:03 +01:00
Don't ask user for privatekey if file can be signed with auth_privatekey
This commit is contained in:
parent
a89f66e8b5
commit
f4a040064c
2 changed files with 35 additions and 28 deletions
|
@ -354,17 +354,18 @@ class Sidebar extends Class
|
|||
@tag.find("#button-sign").off("click touchend").on "click touchend", =>
|
||||
inner_path = @tag.find("#input-contents").val()
|
||||
|
||||
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) =>
|
||||
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
||||
wrapper.ws.cmd "fileRules", {inner_path: inner_path}, (res) =>
|
||||
if wrapper.site_info.privatekey or wrapper.site_info.auth_address in res.signers
|
||||
# Privatekey stored in users.json
|
||||
wrapper.ws.cmd "siteSign", {privatekey: "stored", inner_path: inner_path, update_changed_files: true}, (res) =>
|
||||
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
|
||||
wrapper.ws.cmd "siteSign", {privatekey: privatekey, 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
|
||||
wrapper.ws.cmd "siteSign", {privatekey: privatekey, inner_path: inner_path, update_changed_files: true}, (res) =>
|
||||
if res == "ok"
|
||||
wrapper.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
||||
|
||||
return false
|
||||
|
||||
|
|
|
@ -189,7 +189,8 @@ window.initScrollable = function () {
|
|||
var Sidebar,
|
||||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
hasProp = {}.hasOwnProperty,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
Sidebar = (function(superClass) {
|
||||
extend(Sidebar, superClass);
|
||||
|
@ -600,27 +601,32 @@ window.initScrollable = function () {
|
|||
return function() {
|
||||
var inner_path;
|
||||
inner_path = _this.tag.find("#input-contents").val();
|
||||
if (wrapper.site_info.privatekey) {
|
||||
wrapper.ws.cmd("siteSign", {
|
||||
privatekey: "stored",
|
||||
inner_path: inner_path,
|
||||
update_changed_files: true
|
||||
}, function(res) {
|
||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||
});
|
||||
} else {
|
||||
wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) {
|
||||
wrapper.ws.cmd("fileRules", {
|
||||
inner_path: inner_path
|
||||
}, function(res) {
|
||||
var ref;
|
||||
if (wrapper.site_info.privatekey || (ref = wrapper.site_info.auth_address, indexOf.call(res.signers, ref) >= 0)) {
|
||||
return wrapper.ws.cmd("siteSign", {
|
||||
privatekey: privatekey,
|
||||
privatekey: "stored",
|
||||
inner_path: inner_path,
|
||||
update_changed_files: true
|
||||
}, function(res) {
|
||||
if (res === "ok") {
|
||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||
}
|
||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) {
|
||||
return wrapper.ws.cmd("siteSign", {
|
||||
privatekey: privatekey,
|
||||
inner_path: inner_path,
|
||||
update_changed_files: true
|
||||
}, function(res) {
|
||||
if (res === "ok") {
|
||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
};
|
||||
})(this));
|
||||
|
@ -676,7 +682,7 @@ window.initScrollable = function () {
|
|||
return img.onload = (function(_this) {
|
||||
return function() {
|
||||
return wrapper.ws.cmd("sidebarGetPeers", [], function(globe_data) {
|
||||
var e, ref, ref1;
|
||||
var e, error, ref, ref1;
|
||||
if (_this.globe) {
|
||||
_this.globe.scene.remove(_this.globe.points);
|
||||
_this.globe.addData(globe_data, {
|
||||
|
|
Loading…
Reference in a new issue