implement session stats, fixes last (admin|user) left at won't work for any provider that removed users after logout.

This commit is contained in:
Miroslav Šedivý
2024-09-07 18:55:27 +02:00
parent 356a566bc6
commit 4f401ac2b6
7 changed files with 124 additions and 21 deletions
+12
View File
@@ -52,6 +52,16 @@ type Settings struct {
Plugins PluginSettings `json:"plugins"`
}
type Stats struct {
HasHost bool `json:"has_host"`
HostId string `json:"host_id,omitempty"`
ServerStartedAt time.Time `json:"server_started_at"`
TotalUsers int `json:"total_users"`
LastUserLeftAt *time.Time `json:"last_user_left_at,omitempty"`
TotalAdmins int `json:"total_admins"`
LastAdminLeftAt *time.Time `json:"last_admin_left_at,omitempty"`
}
type Session interface {
ID() string
Profile() MemberProfile
@@ -110,6 +120,8 @@ type SessionManager interface {
Settings() Settings
CookieEnabled() bool
Stats() Stats
CookieSetToken(w http.ResponseWriter, token string)
CookieClearToken(w http.ResponseWriter, r *http.Request)
Authenticate(r *http.Request) (Session, error)