get player ids from sessions, not ips

This commit is contained in:
2024-02-01 08:26:27 -06:00
parent 73b5ac7960
commit 570fc6a298
5 changed files with 76 additions and 66 deletions

View File

@@ -15,6 +15,15 @@ type Session struct {
uuid.UUID
}
// ParseSession parses a session ID.
func ParseSession(s string) (Session, error) {
id, err := uuid.Parse(s)
if err != nil {
return Session{}, fmt.Errorf("couldn't parse session ID: %w", err)
}
return Session{id}, nil
}
// InitSessions initializes an SQLite table relating player IDs to sessions.
func InitSessions(ctx context.Context, db Execer) error {
_, err := db.Exec(ctx, initSessions)