add in config variable for redis sessions

This commit is contained in:
Gregory Wells
2026-06-08 18:44:20 -04:00
parent 11c40a75ac
commit 40429d7618
3 changed files with 15 additions and 5 deletions
+2 -1
View File
@@ -13,7 +13,8 @@
},
"server_config": {
"port": 8080,
"base_url": "https://profile.example.com"
"base_url": "https://profile.example.com",
"session_store": "redis"
},
"email_config": {
"username": "noreply",
+1
View File
@@ -24,6 +24,7 @@ type StyleConfig struct {
type WebserverConfig struct {
Port int `json:"port"`
BaseURL string `json:"base_url"`
SessionStore string `json:"session_store"`
}
type EmailConfig struct {
+10 -2
View File
@@ -221,8 +221,6 @@ func changePasswordHandler(w http.ResponseWriter, r *http.Request) {
func main() {
logging.Info("Starting the server")
sessionManager = session.GetSessionManager()
sessionManager.SetStoreType(session.Redis)
var err error
serverConfig, err = loadServerConfig("./data/config.json")
@@ -230,6 +228,16 @@ func main() {
log.Fatal("Could not load server config")
}
sessionManager = session.GetSessionManager()
if serverConfig.WebserverConfig.SessionStore == "in_memory" {
sessionManager.SetStoreType(session.InMemory)
} else if serverConfig.WebserverConfig.SessionStore == "redis" {
sessionManager.SetStoreType(session.Redis)
} else {
logging.Warnf("'%s' is an unknown session store type defaulting to in memory", serverConfig.WebserverConfig.SessionStore)
sessionManager.SetStoreType(session.InMemory)
}
noReplyEmail = email.CreateEmailAccount(email.EmailAccountData{
Username: serverConfig.EmailConfig.Username,
Password: serverConfig.EmailConfig.Password,