Display confirmation if zeroid already exists
This commit is contained in:
parent
561bd80aa3
commit
9bb0a0d91b
4 changed files with 40 additions and 6 deletions
|
@ -477,11 +477,28 @@ class UiWebsocket(object):
|
||||||
["done", "New certificate added: <b>%s/%s@%s</b>." % (auth_type, auth_user_name, domain)]
|
["done", "New certificate added: <b>%s/%s@%s</b>." % (auth_type, auth_user_name, domain)]
|
||||||
)
|
)
|
||||||
self.response(to, "ok")
|
self.response(to, "ok")
|
||||||
|
elif res is False:
|
||||||
|
# Display confirmation of change
|
||||||
|
cert_current = self.user.certs[domain]
|
||||||
|
body = "You current certificate: <b>%s/%s@%s</b>" % (cert_current["auth_type"], cert_current["auth_user_name"], domain)
|
||||||
|
#body += "<br>Do you want to change it to: <b>%s/%s@%s</b>?" % (auth_type, auth_user_name, domain)
|
||||||
|
self.cmd("confirm", [body, "Change it to %s/%s@%s" % (auth_type, auth_user_name, domain)],
|
||||||
|
lambda (res): self.cbCertAddConfirm(to, domain, auth_type, auth_user_name, cert)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.response(to, "Not changed")
|
self.response(to, "Not changed")
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
self.response(to, {"error": err.message})
|
self.response(to, {"error": err.message})
|
||||||
|
|
||||||
|
def cbCertAddConfirm(self, to, domain, auth_type, auth_user_name, cert):
|
||||||
|
self.user.deleteCert(domain)
|
||||||
|
self.user.addCert(self.user.getAuthAddress(self.site.address), domain, auth_type, auth_user_name, cert)
|
||||||
|
self.cmd(
|
||||||
|
"notification",
|
||||||
|
["done", "Certificate changed to: <b>%s/%s@%s</b>." % (auth_type, auth_user_name, domain)]
|
||||||
|
)
|
||||||
|
self.response(to, "ok")
|
||||||
|
|
||||||
# Select certificate for site
|
# Select certificate for site
|
||||||
def actionCertSelect(self, to, accepted_domains=[]):
|
def actionCertSelect(self, to, accepted_domains=[]):
|
||||||
accounts = []
|
accounts = []
|
||||||
|
|
|
@ -56,6 +56,9 @@ class Wrapper
|
||||||
else if cmd == "prompt" # Prompt input
|
else if cmd == "prompt" # Prompt input
|
||||||
@displayPrompt message.params[0], message.params[1], message.params[2], (res) =>
|
@displayPrompt message.params[0], message.params[1], message.params[2], (res) =>
|
||||||
@ws.response message.id, res
|
@ws.response message.id, res
|
||||||
|
else if cmd == "confirm" # Confirm action
|
||||||
|
@displayConfirm message.params[0], message.params[1], (res) =>
|
||||||
|
@ws.response message.id, res
|
||||||
else if cmd == "setSiteInfo"
|
else if cmd == "setSiteInfo"
|
||||||
@sendInner message # Pass to inner frame
|
@sendInner message # Pass to inner frame
|
||||||
if message.params.address == @address # Current page
|
if message.params.address == @address # Current page
|
||||||
|
@ -173,7 +176,9 @@ class Wrapper
|
||||||
displayConfirm: (message, caption, cb) ->
|
displayConfirm: (message, caption, cb) ->
|
||||||
body = $("<span class='message'>"+message+"</span>")
|
body = $("<span class='message'>"+message+"</span>")
|
||||||
button = $("<a href='##{caption}' class='button button-#{caption}'>#{caption}</a>") # Add confirm button
|
button = $("<a href='##{caption}' class='button button-#{caption}'>#{caption}</a>") # Add confirm button
|
||||||
button.on "click", cb
|
button.on "click", =>
|
||||||
|
cb(true)
|
||||||
|
return false
|
||||||
body.append(button)
|
body.append(button)
|
||||||
@notifications.add("notification-#{caption}", "ask", body)
|
@notifications.add("notification-#{caption}", "ask", body)
|
||||||
|
|
||||||
|
|
|
@ -830,6 +830,12 @@ jQuery.extend( jQuery.easing,
|
||||||
return _this.ws.response(message.id, res);
|
return _this.ws.response(message.id, res);
|
||||||
};
|
};
|
||||||
})(this));
|
})(this));
|
||||||
|
} else if (cmd === "confirm") {
|
||||||
|
return this.displayConfirm(message.params[0], message.params[1], (function(_this) {
|
||||||
|
return function(res) {
|
||||||
|
return _this.ws.response(message.id, res);
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
} else if (cmd === "setSiteInfo") {
|
} else if (cmd === "setSiteInfo") {
|
||||||
this.sendInner(message);
|
this.sendInner(message);
|
||||||
if (message.params.address === this.address) {
|
if (message.params.address === this.address) {
|
||||||
|
@ -972,7 +978,12 @@ jQuery.extend( jQuery.easing,
|
||||||
var body, button;
|
var body, button;
|
||||||
body = $("<span class='message'>" + message + "</span>");
|
body = $("<span class='message'>" + message + "</span>");
|
||||||
button = $("<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>");
|
button = $("<a href='#" + caption + "' class='button button-" + caption + "'>" + caption + "</a>");
|
||||||
button.on("click", cb);
|
button.on("click", (function(_this) {
|
||||||
|
return function() {
|
||||||
|
cb(true);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
})(this));
|
||||||
body.append(button);
|
body.append(button);
|
||||||
this.notifications.add("notification-" + caption, "ask", body);
|
this.notifications.add("notification-" + caption, "ask", body);
|
||||||
button.focus();
|
button.focus();
|
||||||
|
|
|
@ -110,10 +110,7 @@ class User(object):
|
||||||
}
|
}
|
||||||
# Check if we have already cert for that domain and its not the same
|
# Check if we have already cert for that domain and its not the same
|
||||||
if self.certs.get(domain) and self.certs[domain] != cert_node:
|
if self.certs.get(domain) and self.certs[domain] != cert_node:
|
||||||
raise Exception(
|
return False
|
||||||
"You already have certificate for this domain: %s/%s@%s" %
|
|
||||||
(self.certs[domain]["auth_type"], self.certs[domain]["auth_user_name"], domain)
|
|
||||||
)
|
|
||||||
elif self.certs.get(domain) == cert_node: # Same, not updated
|
elif self.certs.get(domain) == cert_node: # Same, not updated
|
||||||
return None
|
return None
|
||||||
else: # Not exist yet, add
|
else: # Not exist yet, add
|
||||||
|
@ -121,6 +118,10 @@ class User(object):
|
||||||
self.save()
|
self.save()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
# Remove cert from user
|
||||||
|
def deleteCert(self, domain):
|
||||||
|
del self.certs[domain]
|
||||||
|
|
||||||
# Set active cert for a site
|
# Set active cert for a site
|
||||||
def setCert(self, address, domain):
|
def setCert(self, address, domain):
|
||||||
site_data = self.getSiteData(address)
|
site_data = self.getSiteData(address)
|
||||||
|
|
Loading…
Reference in a new issue