Print username instead of accountname when asking for password (issue #558)
When asking for a password interactively, the username is never displayed which may hide problems (typos on the configuration, or issues on offlineimap parsing of the config file). The hostname, port, and account name are already displayed when establishing the connection. When asking for password, the account name is displayed again. Change it to display the username.
This commit is contained in:
parent
c865dcc03c
commit
950702d605
|
@ -175,8 +175,7 @@ class IMAPServer(object):
|
|||
|
||||
# get 1) configured password first 2) fall back to asking via UI
|
||||
self.password = self.repos.getpassword() or \
|
||||
self.ui.getpass(self.repos.getname(), self.config,
|
||||
self.passworderror)
|
||||
self.ui.getpass(self.username, self.config, self.passworderror)
|
||||
self.passworderror = None
|
||||
return self.password
|
||||
|
||||
|
|
|
@ -549,7 +549,7 @@ class Blinkenlights(UIBase, CursesUtil):
|
|||
def mainException(self):
|
||||
UIBase.mainException(self)
|
||||
|
||||
def getpass(self, accountname, config, errmsg=None):
|
||||
def getpass(self, username, config, errmsg=None):
|
||||
# disable the hotkeys inputhandler
|
||||
self.inputhandler.input_acquire()
|
||||
|
||||
|
@ -558,8 +558,8 @@ class Blinkenlights(UIBase, CursesUtil):
|
|||
try:
|
||||
#s.gettf().setcolor('white')
|
||||
self.warn(" *** Input Required")
|
||||
self.warn(" *** Please enter password for account %s: " % \
|
||||
accountname)
|
||||
self.warn(" *** Please enter password for user '%s': " % \
|
||||
username)
|
||||
self.logwin.refresh()
|
||||
password = self.logwin.getstr()
|
||||
finally:
|
||||
|
|
|
@ -182,15 +182,15 @@ class MachineUI(UIBase):
|
|||
return 0
|
||||
|
||||
|
||||
def getpass(s, accountname, config, errmsg=None):
|
||||
def getpass(s, username, config, errmsg=None):
|
||||
if errmsg:
|
||||
s._printData(s.logger.warning,
|
||||
'getpasserror', "%s\n%s"% (accountname, errmsg),
|
||||
'getpasserror', "%s\n%s"% (username, errmsg),
|
||||
False)
|
||||
|
||||
s._log_con_handler.acquire() # lock the console output
|
||||
try:
|
||||
s._printData(s.logger.info, 'getpass', accountname)
|
||||
s._printData(s.logger.info, 'getpass', username)
|
||||
return (sys.stdin.readline()[:-1])
|
||||
finally:
|
||||
s._log_con_handler.release()
|
||||
|
|
|
@ -76,14 +76,14 @@ class TTYUI(UIBase):
|
|||
|
||||
return sys.stdout.isatty() and sys.stdin.isatty()
|
||||
|
||||
def getpass(self, accountname, config, errmsg=None):
|
||||
def getpass(self, username, config, errmsg=None):
|
||||
"""TTYUI backend is capable of querying the password."""
|
||||
|
||||
if errmsg:
|
||||
self.warn("%s: %s"% (accountname, errmsg))
|
||||
self.warn("%s: %s"% (username, errmsg))
|
||||
self._log_con_handler.acquire() # lock the console output
|
||||
try:
|
||||
return getpass("Enter password for account '%s': " % accountname)
|
||||
return getpass("Enter password for user '%s': " % username)
|
||||
finally:
|
||||
self._log_con_handler.release()
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ class UIBase(object):
|
|||
|
||||
################################################## INPUT
|
||||
|
||||
def getpass(self, accountname, config, errmsg = None):
|
||||
def getpass(self, username, config, errmsg = None):
|
||||
raise NotImplementedError("Prompting for a password is not supported"
|
||||
" in this UI backend.")
|
||||
|
||||
|
|
Loading…
Reference in New Issue