diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-10-26 14:11:40 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-10-26 14:11:40 +0200 |
commit | 0aa91b4dc70c0290a6a1e9b94ef1eb0187b06984 (patch) | |
tree | b3efeb15ef14975a7364367823ee2fcfec726cb1 | |
parent | 098d0c123de9251f46a40e228e12b99d92acc9cc (diff) | |
download | server-0aa91b4dc70c0290a6a1e9b94ef1eb0187b06984.tar.gz |
Delete old password recovery tokens on startup.
-rw-r--r-- | server.js | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -71,6 +71,9 @@ setInterval(LOG_STATS, 30 * 1000) let db = new sqlite3(process.env.DATABASE || "./db") db.pragma("synchronous = NORMAL") +db.exec("delete from logins where julianday() > expires") +db.exec("delete from tokens where julianday() > time + 1") + function SQL(s) { return db.prepare(s) } @@ -120,7 +123,6 @@ if (process.env.MAIL_HOST && process.env.MAIL_PORT && process.env.MAIL_FROM) { const COOKIE = (process.env.COOKIE || "login") + "=" -db.exec("delete from logins where expires < julianday()") const login_sql_select = SQL("select user_id from logins where sid = ? and expires > julianday()").pluck() const login_sql_insert = SQL("insert into logins values (abs(random()) % (1<<48), ?, julianday() + 28) returning sid").pluck() const login_sql_delete = SQL("delete from logins where sid = ?") |