From c3b0e1dec41bb2c4fa75842ed4ce25b78f0dc6e7 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Mon, 22 Feb 2016 14:03:02 +0530 Subject: [PATCH] Returns an error when the driver couldn't decrypt the password, and let the user know the issue. --- web/pgadmin/utils/driver/psycopg2/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index 2bc89ea51..3badf3fb8 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -102,7 +102,15 @@ class Connection(BaseConnection): if user is None: return False, gettext("Unauthorized Request.") - password = decrypt(encpass, user.password) + try: + password = decrypt(encpass, user.password) + except Exception as e: + current_app.logger.exception(e) + return False, \ + _("Failed to decrypt the saved password!\nError: {0}").format( + str(e) + ) + # password is in bytes, for python3 we need it in string if isinstance(password, bytes): password = password.decode()