rename session manager functions
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user