Feat: add models/cache/config

This commit is contained in:
Grail Finder
2025-05-02 09:06:17 +03:00
parent dbc87d7b9b
commit acaf4af4ce
13 changed files with 554 additions and 1 deletions

25
models/auth.go Normal file
View File

@ -0,0 +1,25 @@
package models
import (
"time"
)
// each session contains the username of the user and the time at which it expires
type Session struct {
Username string
CurrentRoom string
Expiry time.Time
}
// we'll use this method later to determine if the session has expired
func (s Session) IsExpired() bool {
return s.Expiry.Before(time.Now())
}
func ListUsernames(ss map[string]*Session) []string {
resp := make([]string, 0, len(ss))
for _, s := range ss {
resp = append(resp, s.Username)
}
return resp
}