diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-11-01 23:31:03 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-11-01 23:31:03 +0100 |
commit | d18f9d3b0e4f16c3ec6e2f41ff567e0e2891bbf0 (patch) | |
tree | 197a26089c44177ad53cc9f5415f9a096d16344c /src/jwebmail | |
parent | eae0a7398ee06165180393031080aa12df20303c (diff) |
refresh session timeout on access
Diffstat (limited to 'src/jwebmail')
-rw-r--r-- | src/jwebmail/__init__.py | 2 | ||||
-rw-r--r-- | src/jwebmail/read_mails.py | 11 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/jwebmail/__init__.py b/src/jwebmail/__init__.py index dd1335c..631215b 100644 --- a/src/jwebmail/__init__.py +++ b/src/jwebmail/__init__.py @@ -36,7 +36,7 @@ else: toml_read_file = dict(load=toml_load, text=True) -__version__ = "2.3.0.dev2" +__version__ = "2.3.0.dev3" csrf = CSRFProtect() diff --git a/src/jwebmail/read_mails.py b/src/jwebmail/read_mails.py index 01252ee..44eba8d 100644 --- a/src/jwebmail/read_mails.py +++ b/src/jwebmail/read_mails.py @@ -61,11 +61,18 @@ class MysqlTimeoutSession: cur.execute("DELETE FROM session WHERE timeout < NOW()") cur.execute("SELECT password FROM session WHERE user = %s", [key]) row = cur.fetchone() - self.conn.commit() - cur.close() + if row is None: + self.conn.commit() + cur.close() return None else: + timeout = datetime.now() + timedelta(seconds=self.timeout) + cur.execute( + "UPDATE session SET timeout = %s WHERE user = %s", [timeout, key] + ) + self.conn.commit() + cur.close() return row[0] |