summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/db.go1
-rw-r--r--db/session.go10
2 files changed, 10 insertions, 1 deletions
diff --git a/db/db.go b/db/db.go
index 87784ff..3a48858 100644
--- a/db/db.go
+++ b/db/db.go
@@ -50,6 +50,7 @@ type Model interface {
CreateSession(user User) (Session, error)
DeleteSession(session Session) error
+ TouchSession(session Session) error
CheckSession(session Session) (bool, error)
CleanSessions(maxIdle time.Duration) error
AllSessions() ([]Session, error)
diff --git a/db/session.go b/db/session.go
index bddedda..b8365ff 100644
--- a/db/session.go
+++ b/db/session.go
@@ -73,6 +73,14 @@ func extractSession(s Scanner) (Session, error) {
}
+func (p *Phlox) TouchSession(session Session) error {
+ now := time.Now().UTC()
+ nowStr := now.Format(time.RFC3339)
+ _, err := p.db.Exec("update sessions set modified=? where sessionid=?;", nowStr, session.Id)
+ return err
+}
+
+
func (p *Phlox) CheckSession(session Session) (bool, error) {
row := p.db.QueryRow("select * from sessions where sessionid = ?", session.Id)
session, err := extractSession(row)
@@ -96,7 +104,7 @@ func (p *Phlox) TouchSession(session Session) error {
"update sessions set modified = ? where sessionid = ?;",
now, session.Id,
)
- return err
+ return err
}