Commit: Bulk unfinished work

This commit is contained in:
2026-01-22 17:39:04 +01:00
parent 6c46b4efcc
commit 3a9acc42a2
68 changed files with 5047 additions and 1064 deletions

View File

@@ -0,0 +1,44 @@
package stores
import (
"errors"
"strconv"
)
type Session struct {
Token string
UserID uint
MandantId uint
}
func (s *Session) Deserialize(t string, m map[string]string) (*Session, error) {
userid, err := strconv.Atoi(m["userid"])
if err != nil {
return nil, errors.New("Userid from cache not an int")
}
mandantid, err := strconv.Atoi(m["mandantid"])
if err != nil {
return nil, errors.New("Mandantid from cache not an int")
}
s.Token = t
s.UserID = uint(userid)
s.MandantId = uint(mandantid)
return s, nil
}
func (s *Session) Serialize() map[string]string {
m := make(map[string]string)
m["userid"] = strconv.Itoa(int(s.UserID))
m["mandantid"] = strconv.Itoa(int(s.MandantId))
return m
}
type SessionStore interface {
AddSession(s *Session)
GetSessionFromToken(token string) (*Session, error)
RemoveSession(token string)
SetMandantInSession(token string, mandantId uint) error
}