summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2022-01-13 09:27:47 -0800
committerAmjith Ramanujam <amjith.r@gmail.com>2022-01-13 09:27:47 -0800
commit338ea2186eeb8679be0dd8ecb1dfa0494df3f125 (patch)
treec8986bacda233d45ca7cb0cfd4d2f6254fe78bef
parent6d719b628d2085198f22801da38ce7f666c79d55 (diff)
Change the order for password prompt and keychain.
-rw-r--r--pgcli/main.py21
1 files changed, 11 insertions, 10 deletions
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