rename session manager functions

This commit is contained in:
2026-04-03 18:24:50 -04:00
parent bb649aef48
commit 3a3fab08f6

View File

@@ -23,20 +23,24 @@ const (
InMemory StoreType = iota InMemory StoreType = iota
) )
func CreateSessionManager(storeType StoreType) *SessionManager { func GetSessionManager() *SessionManager {
once.Do(func() { once.Do(func() {
instance = &SessionManager{} instance = &SessionManager{}
switch storeType {
case InMemory:
{
instance.store = NewMemoryStore()
break
}
}
}) })
return instance return instance
} }
func (manager *SessionManager) SetStoreType(storeType StoreType) {
logging.Infof("Changing session manager store type")
switch storeType {
case InMemory:
{
manager.store = NewMemoryStore()
break
}
}
}
func (manager *SessionManager) CreateSession(userID string) (cookie *http.Cookie, err error) { func (manager *SessionManager) CreateSession(userID string) (cookie *http.Cookie, err error) {
logging.Debugf("Creating a new session for %s", userID) logging.Debugf("Creating a new session for %s", userID)
token, err := GenerateSessionToken(32) // Use crypto/rand for this token, err := GenerateSessionToken(32) // Use crypto/rand for this