MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / actionCertAdd

Method actionCertAdd

src/Ui/UiWebsocket.py:730–754  ·  view source on GitHub ↗
(self, to, domain, auth_type, auth_user_name, cert)

Source from the content-addressed store, hash-verified

728
729 # Add certificate to user
730 def actionCertAdd(self, to, domain, auth_type, auth_user_name, cert):
731 try:
732 res = self.user.addCert(self.user.getAuthAddress(self.site.address), domain, auth_type, auth_user_name, cert)
733 if res is True:
734 self.cmd(
735 "notification",
736 ["done", _("{_[New certificate added]:} <b>{auth_type}/{auth_user_name}@{domain}</b>.")]
737 )
738 self.user.setCert(self.site.address, domain)
739 self.site.updateWebsocket(cert_changed=domain)
740 self.response(to, "ok")
741 elif res is False:
742 # Display confirmation of change
743 cert_current = self.user.certs[domain]
744 body = _("{_[Your current certificate]:} <b>{cert_current[auth_type]}/{cert_current[auth_user_name]}@{domain}</b>")
745 self.cmd(
746 "confirm",
747 [body, _("Change it to {auth_type}/{auth_user_name}@{domain}")],
748 lambda res: self.cbCertAddConfirm(to, domain, auth_type, auth_user_name, cert)
749 )
750 else:
751 self.response(to, "Not changed")
752 except Exception as err:
753 self.log.error("CertAdd error: Exception - %s (%s)" % (err.message, Debug.formatException(err)))
754 self.response(to, {"error": err.message})
755
756 def cbCertAddConfirm(self, to, domain, auth_type, auth_user_name, cert):
757 self.user.deleteCert(domain)

Callers

nothing calls this directly

Calls 9

cmdMethod · 0.95
responseMethod · 0.95
cbCertAddConfirmMethod · 0.95
addCertMethod · 0.80
getAuthAddressMethod · 0.80
setCertMethod · 0.80
errorMethod · 0.80
_Function · 0.50
updateWebsocketMethod · 0.45

Tested by

no test coverage detected