summaryrefslogtreecommitdiff
path: root/src/jwebmail/read_mails.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/jwebmail/read_mails.py')
-rw-r--r--src/jwebmail/read_mails.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/jwebmail/read_mails.py b/src/jwebmail/read_mails.py
index 54bd139..7775b12 100644
--- a/src/jwebmail/read_mails.py
+++ b/src/jwebmail/read_mails.py
@@ -5,7 +5,7 @@ from os.path import join as path_join
from flask import current_app, g
from flask_login import UserMixin, current_user, login_user
-from .model.read_mails import QMailAuthuser
+from .model.read_mails import QMailAuthuser, QMAuthError
EXPIRATION_SEC = 60 * 60 * 25
@@ -163,8 +163,15 @@ def _build_qma(username, password):
def login(username, password):
- if not _build_qma(username, password).verify_user():
- return False
+ try:
+ qma = _build_qma(username, password).open()
+ except QMAuthError as err:
+ if err.rc == 1:
+ return False
+ else:
+ raise
+ finally:
+ qma.close()
r = _select_timeout_session()
r.set(username, password)
r.close()
@@ -186,6 +193,6 @@ def get_read_mails_logged_in():
if "read_mails" in g:
return g.read_mails
- qma = _build_qma(current_user.get_id(), current_user.password)
+ qma = _build_qma(current_user.get_id(), current_user.password).open()
g.read_mails = qma
return qma