[mod/ux] display the real error when failed to retrieve session

This commit is contained in:
Laurent Peuch 2019-07-23 03:59:39 +02:00
parent 9c6c92b2c1
commit 79347af868
2 changed files with 6 additions and 6 deletions

View file

@ -31,7 +31,7 @@
"server_already_running": "A server is already running on that port", "server_already_running": "A server is already running on that port",
"success": "Success!", "success": "Success!",
"unable_authenticate": "Unable to authenticate", "unable_authenticate": "Unable to authenticate",
"unable_retrieve_session": "Unable to retrieve the session", "unable_retrieve_session": "Unable to retrieve the session because '{exception}'",
"unknown_group": "Unknown '{group}' group", "unknown_group": "Unknown '{group}' group",
"unknown_user": "Unknown '{user}' user", "unknown_user": "Unknown '{user}' user",
"values_mismatch": "Values don't match", "values_mismatch": "Values don't match",

View file

@ -152,16 +152,16 @@ class BaseAuthenticator(object):
try: try:
with self._open_sessionfile(session_id, 'r') as f: with self._open_sessionfile(session_id, 'r') as f:
enc_pwd = f.read() enc_pwd = f.read()
except IOError: except IOError as e:
logger.debug("unable to retrieve session", exc_info=1) logger.debug("unable to retrieve session", exc_info=1)
raise MoulinetteError('unable_retrieve_session') raise MoulinetteError('unable_retrieve_session', exception=e)
else: else:
gpg = gnupg.GPG() gpg = gnupg.GPG()
gpg.encoding = 'utf-8' gpg.encoding = 'utf-8'
decrypted = gpg.decrypt(enc_pwd, passphrase=session_hash) decrypted = gpg.decrypt(enc_pwd, passphrase=session_hash)
if decrypted.ok is not True: if decrypted.ok is not True:
logger.error("unable to decrypt password for the session: %s", error_message = "unable to decrypt password for the session: %s", decrypted.status
decrypted.status) logger.error(error_message)
raise MoulinetteError('unable_retrieve_session') raise MoulinetteError('unable_retrieve_session', exception=error_message)
return decrypted.data return decrypted.data