Enha: use of sql sessions

This commit is contained in:
Grail Finder
2025-07-03 08:15:54 +03:00
parent 130ed3763b
commit e02554b181
10 changed files with 36 additions and 25 deletions

View File

@ -6,19 +6,19 @@ import (
// each session contains the username of the user and the time at which it expires
type Session struct {
ID uint32
ID uint32 `db:"id"`
// CurrentRoom string
// Expiry time.Time
UpdatedAt time.Time
Lifetime uint32 // minutes
CookieToken string
Username string // username is playerid
UpdatedAt time.Time `db:"updated_at"`
Lifetime uint32 `db:"lifetime"` // minutes
TokenKey string `db:"token_key"`
Username string `db:"username"` // username is playerid
}
// we'll use this method later to determine if the session has expired
func (s Session) IsExpired() bool {
return time.Now().After(s.UpdatedAt.Add(time.Minute * time.Duration(s.Lifetime)))
// return s.Expiry.Before(time.Now())
// return time.Now().After(s.UpdatedAt.Add(time.Minute * time.Duration(s.Lifetime)))
return false
}
// func ListUsernames(ss map[string]*Session) []string {