fix: guard against nil session storage
This commit is contained in:
parent
956e74a6b3
commit
aa8322c354
|
|
@ -45,6 +45,10 @@ func RegisterUserSession(cfg *config.Config, provider string, sid string, userna
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sessionStorage.Providers == nil {
|
||||||
|
sessionStorage.Providers = make(map[string]*SessionProvider)
|
||||||
|
}
|
||||||
|
|
||||||
sessionStorage.Providers[provider].Sessions[sid] = &UserSession{
|
sessionStorage.Providers[provider].Sessions[sid] = &UserSession{
|
||||||
Username: username,
|
Username: username,
|
||||||
Expiry: time.Now().Unix() + 31556952, // 1 year
|
Expiry: time.Now().Unix() + 31556952, // 1 year
|
||||||
|
|
@ -55,8 +59,8 @@ func RegisterUserSession(cfg *config.Config, provider string, sid string, userna
|
||||||
|
|
||||||
// GetUserSession retrieves a user session
|
// GetUserSession retrieves a user session
|
||||||
func GetUserSession(provider string, sid string) *UserSession {
|
func GetUserSession(provider string, sid string) *UserSession {
|
||||||
sessionStorageMutex.RLock()
|
sessionStorageMutex.Lock()
|
||||||
defer sessionStorageMutex.RUnlock()
|
defer sessionStorageMutex.Unlock()
|
||||||
|
|
||||||
if sessionStorage.Providers[provider] == nil {
|
if sessionStorage.Providers[provider] == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue