From 5f9474e10dfe4e7aad858dfe5799291eef2337fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Wed, 13 Jun 2018 13:05:13 +0100 Subject: [PATCH] Print username instead of accountname when asking for password 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. Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/558 Signed-off-by: David Miguel Susano Pinto Signed-off-by: Nicolas Sebrecht --- offlineimap/imapserver.py | 3 +-- offlineimap/ui/Curses.py | 6 +++--- offlineimap/ui/Machine.py | 6 +++--- offlineimap/ui/TTY.py | 6 +++--- offlineimap/ui/UIBase.py | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/offlineimap/imapserver.py b/offlineimap/imapserver.py index 9075b80..79163f2 100644 --- a/offlineimap/imapserver.py +++ b/offlineimap/imapserver.py @@ -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 diff --git a/offlineimap/ui/Curses.py b/offlineimap/ui/Curses.py index e97bed0..04119aa 100644 --- a/offlineimap/ui/Curses.py +++ b/offlineimap/ui/Curses.py @@ -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: diff --git a/offlineimap/ui/Machine.py b/offlineimap/ui/Machine.py index ae3eab8..ed0411e 100644 --- a/offlineimap/ui/Machine.py +++ b/offlineimap/ui/Machine.py @@ -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() diff --git a/offlineimap/ui/TTY.py b/offlineimap/ui/TTY.py index 7113b6a..5a0a517 100644 --- a/offlineimap/ui/TTY.py +++ b/offlineimap/ui/TTY.py @@ -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() diff --git a/offlineimap/ui/UIBase.py b/offlineimap/ui/UIBase.py index 10993ff..94f9f02 100644 --- a/offlineimap/ui/UIBase.py +++ b/offlineimap/ui/UIBase.py @@ -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.")