Merge pull request #1524 from letsencrypt/email

Better UI when asking for email
This commit is contained in:
Peter Eckersley
2015-11-20 19:16:02 -08:00
8 changed files with 115 additions and 25 deletions
+22 -9
View File
@@ -122,23 +122,36 @@ def pick_configurator(
config, default, plugins, question,
(interfaces.IAuthenticator, interfaces.IInstaller))
def get_email():
def get_email(more=False, invalid=False):
"""Prompt for valid email address.
:param bool more: explain why the email is strongly advisable, but how to
skip it
:param bool invalid: true if the user just typed something, but it wasn't
a valid-looking email
:returns: Email or ``None`` if cancelled by user.
:rtype: str
"""
while True:
code, email = zope.component.getUtility(interfaces.IDisplay).input(
"Enter email address (used for urgent notices and lost key recovery)")
msg = "Enter email address (used for urgent notices and lost key recovery)"
if invalid:
msg = "There seem to be problems with that address. " + msg
if more:
msg += ('\n\nIf you really want to skip this, you can run the client with '
'--register-unsafely-without-email but make sure you backup your '
'account key from /etc/letsencrypt/accounts\n\n')
code, email = zope.component.getUtility(interfaces.IDisplay).input(msg)
if code == display_util.OK:
if le_util.safe_email(email):
return email
if code == display_util.OK:
if le_util.safe_email(email):
return email
else:
return None
# TODO catch the server's ACME invalid email address error, and
# make a similar call when that happens
return get_email(more=True, invalid=(email != ""))
else:
return None
def choose_account(accounts):
+7 -1
View File
@@ -104,6 +104,7 @@ class NcursesDisplay(object):
return code, int(tag) - 1
def input(self, message):
"""Display an input box to the user.
@@ -114,7 +115,12 @@ class NcursesDisplay(object):
`string` - input entered by the user
"""
return self.dialog.inputbox(message, width=self.width)
sections = message.split("\n")
# each section takes at least one line, plus extras if it's longer than self.width
wordlines = [1 + (len(section)/self.width) for section in sections]
height = 6 + sum(wordlines) + len(sections)
return self.dialog.inputbox(message, width=self.width, height=height)
def yesno(self, message, yes_label="Yes", no_label="No"):
"""Display a Yes/No dialog box.