summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2022-01-13 16:02:50 -0800
committerGitHub <noreply@github.com>2022-01-13 16:02:50 -0800
commit1ea687e1978e977eb995ee2e4ae73bb2ff22ba63 (patch)
tree178818c4df54670e6fd2043f7daf33f9dd2304e8
parent6d719b628d2085198f22801da38ce7f666c79d55 (diff)
parenta082b7cb720aebb74ec40de5c526dc6a2c885a20 (diff)
Merge pull request #1308 from dbcli/always_ask_password-w
Always ask password w
-rw-r--r--changelog.rst5
-rw-r--r--pgcli/main.py21
2 files changed, 14 insertions, 12 deletions
diff --git a/changelog.rst b/changelog.rst
index 7ce5132d..e02e1f24 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -1,5 +1,5 @@
TBD
-================
+===
Features:
---------
@@ -8,10 +8,11 @@ Features:
Bug fixes:
----------
+* Prompt for password when -W is provided even if there is a password in keychain. Fixes #1307.
3.3.0 (2022/01/11)
-================
+==================
Features:
---------
diff --git a/pgcli/main.py b/pgcli/main.py
index 5395f673..e4a2ee39 100644
--- a/pgcli/main.py
+++ b/pgcli/main.py
@@ -549,6 +549,17 @@ class PGCli:
- uninstall keyring: pip uninstall keyring
- disable keyring in our configuration: add keyring = False to [main]"""
)
+
+ # Prompt for a password immediately if requested via the -W flag. This
+ # avoids wasting time trying to connect to the database and catching a
+ # no-password exception.
+ # If we successfully parsed a password from a URI, there's no need to
+ # prompt for it, even with the -W flag
+ if self.force_passwd_prompt and not passwd:
+ passwd = click.prompt(
+ "Password for %s" % user, hide_input=True, show_default=False, type=str
+ )
+
if not passwd and keyring:
try:
@@ -562,16 +573,6 @@ class PGCli:
fg="red",
)
- # Prompt for a password immediately if requested via the -W flag. This
- # avoids wasting time trying to connect to the database and catching a
- # no-password exception.
- # If we successfully parsed a password from a URI, there's no need to
- # prompt for it, even with the -W flag
- if self.force_passwd_prompt and not passwd:
- passwd = click.prompt(
- "Password for %s" % user, hide_input=True, show_default=False, type=str
- )
-
def should_ask_for_password(exc):
# Prompt for a password after 1st attempt to connect
# fails. Don't prompt if the -w flag is supplied