summaryrefslogtreecommitdiff
path: root/db/session.go
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-05-10 15:17:18 -0500
committersanine-a <sanine.not@pm.me>2023-05-10 15:17:18 -0500
commit609ef3f3b4d4cb355d80b19df1e91db258b0bbe0 (patch)
treef5681d28f031241717b72daf117b82d954e9117e /db/session.go
parent2aac43407d7b2699d956b7c626da4f45c802c53c (diff)
log out after 1 hour of inactivity
Diffstat (limited to 'db/session.go')
-rw-r--r--db/session.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/db/session.go b/db/session.go
index da081f9..7ebb6df 100644
--- a/db/session.go
+++ b/db/session.go
@@ -22,8 +22,8 @@ func (p *Phlox) CreateSession(user User) (Session, error) {
nowStr := now.Format(time.RFC3339)
_, err = p.db.Exec(
- "insert into sessions (sessionid, userid, created, modified) values (?, ?, ?, ?);",
- sessionid,
+ "insert into sessions (sessionid, userid, created, modified) values (?, ?, ?, ?);",
+ sessionid,
userid,
nowStr, nowStr,
)
@@ -107,6 +107,11 @@ func (p *Phlox) TouchSession(session Session) error {
}
+func (p *Phlox) TouchSessionId(id string) error {
+ return p.TouchSession(Session{ Id: id })
+}
+
+
func (p *Phlox) CleanSessions(maxIdle time.Duration) error {
expire := time.Now().UTC().Add(-maxIdle).Format(time.RFC3339)
_, err := p.db.Exec("delete from sessions where modified < ?;", expire)