diff options
author | sanine-a <sanine.not@pm.me> | 2023-05-10 15:17:18 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-05-10 15:17:18 -0500 |
commit | 609ef3f3b4d4cb355d80b19df1e91db258b0bbe0 (patch) | |
tree | f5681d28f031241717b72daf117b82d954e9117e /db | |
parent | 2aac43407d7b2699d956b7c626da4f45c802c53c (diff) |
log out after 1 hour of inactivity
Diffstat (limited to 'db')
-rw-r--r-- | db/session.go | 9 |
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) |