diff options
author | Grail Finder <wohilas@gmail.com> | 2025-03-29 11:12:53 +0300 |
---|---|---|
committer | Grail Finder <wohilas@gmail.com> | 2025-03-29 11:12:53 +0300 |
commit | 3921db6166e2da895257496bb76dd115556699d3 (patch) | |
tree | 1be4f739121761085f69cb7706c60dbbe98a93e9 /internal/models/auth.go |
init
Diffstat (limited to 'internal/models/auth.go')
-rw-r--r-- | internal/models/auth.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/models/auth.go b/internal/models/auth.go new file mode 100644 index 0000000..9964cd5 --- /dev/null +++ b/internal/models/auth.go @@ -0,0 +1,24 @@ +package models + +import ( + "time" +) + +// each session contains the username of the user and the time at which it expires +type Session struct { + Username 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 +} |