summaryrefslogtreecommitdiff
path: root/internal/models/auth.go
blob: 5dadf8a10a39d75ad0a645395da9e6b89cabfd6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
}