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,7 +354,8 @@ class Sidebar extends Class
|
||||||
@tag.find("#button-sign").off("click touchend").on "click touchend", =>
|
@tag.find("#button-sign").off("click touchend").on "click touchend", =>
|
||||||
inner_path = @tag.find("#input-contents").val()
|
inner_path = @tag.find("#input-contents").val()
|
||||||
|
|
||||||
if wrapper.site_info.privatekey
|
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
|
# Privatekey stored in users.json
|
||||||
wrapper.ws.cmd "siteSign", {privatekey: "stored", inner_path: inner_path, update_changed_files: true}, (res) =>
|
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.notifications.add "sign", "done", "#{inner_path} Signed!", 5000
|
||||||
|
|
|
@ -189,7 +189,8 @@ window.initScrollable = function () {
|
||||||
var Sidebar,
|
var Sidebar,
|
||||||
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
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; },
|
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) {
|
Sidebar = (function(superClass) {
|
||||||
extend(Sidebar, superClass);
|
extend(Sidebar, superClass);
|
||||||
|
@ -600,8 +601,12 @@ window.initScrollable = function () {
|
||||||
return function() {
|
return function() {
|
||||||
var inner_path;
|
var inner_path;
|
||||||
inner_path = _this.tag.find("#input-contents").val();
|
inner_path = _this.tag.find("#input-contents").val();
|
||||||
if (wrapper.site_info.privatekey) {
|
wrapper.ws.cmd("fileRules", {
|
||||||
wrapper.ws.cmd("siteSign", {
|
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: "stored",
|
privatekey: "stored",
|
||||||
inner_path: inner_path,
|
inner_path: inner_path,
|
||||||
update_changed_files: true
|
update_changed_files: true
|
||||||
|
@ -609,7 +614,7 @@ window.initScrollable = function () {
|
||||||
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
return wrapper.notifications.add("sign", "done", inner_path + " Signed!", 5000);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) {
|
return wrapper.displayPrompt("Enter your private key:", "password", "Sign", "", function(privatekey) {
|
||||||
return wrapper.ws.cmd("siteSign", {
|
return wrapper.ws.cmd("siteSign", {
|
||||||
privatekey: privatekey,
|
privatekey: privatekey,
|
||||||
inner_path: inner_path,
|
inner_path: inner_path,
|
||||||
|
@ -621,6 +626,7 @@ window.initScrollable = function () {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
|
@ -676,7 +682,7 @@ window.initScrollable = function () {
|
||||||
return img.onload = (function(_this) {
|
return img.onload = (function(_this) {
|
||||||
return function() {
|
return function() {
|
||||||
return wrapper.ws.cmd("sidebarGetPeers", [], function(globe_data) {
|
return wrapper.ws.cmd("sidebarGetPeers", [], function(globe_data) {
|
||||||
var e, ref, ref1;
|
var e, error, ref, ref1;
|
||||||
if (_this.globe) {
|
if (_this.globe) {
|
||||||
_this.globe.scene.remove(_this.globe.points);
|
_this.globe.scene.remove(_this.globe.points);
|
||||||
_this.globe.addData(globe_data, {
|
_this.globe.addData(globe_data, {
|
||||||
|
|
Loading…
Reference in a new issue