summaryrefslogtreecommitdiff
path: root/internal/models
diff options
context:
space:
mode:
authorGrailFinder <wohilas@gmail.com>2024-04-20 07:45:00 +0300
committerGrailFinder <wohilas@gmail.com>2024-04-20 07:45:00 +0300
commitb33be53ea9c0be523988a9412fd8e3f6a24782b3 (patch)
tree2f05cbfc78613f1771eb8143105859983cb91750 /internal/models
parentac70f43c3e52e35195353c73af5687b8286ff581 (diff)
Feat: add auth [wip]
Diffstat (limited to 'internal/models')
-rw-r--r--internal/models/auth.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/models/auth.go b/internal/models/auth.go
new file mode 100644
index 0000000..5dadf8a
--- /dev/null
+++ b/internal/models/auth.go
@@ -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
+}