reid 2 anos atrás
pai
commit
a54bde6e47
1 arquivos alterados com 30 adições e 0 exclusões
  1. 30 0
      config/config.go

+ 30 - 0
config/config.go

@@ -95,6 +95,36 @@ func init() {
 		errmsg := fmt.Sprintf("Error decoding JSON: %v", err)
 		Logger.Error(errmsg)
 	}
+	// wipe the sessions on each startup
+	globalConfig.Sessions.Authorized = make(map[string]structs.SessionInfo)
+	globalConfig.Sessions.Unauthorized = make(map[string]structs.SessionInfo)
+	configMap := make(map[string]interface{})
+	configBytes, err := json.Marshal(globalConfig)
+	if err != nil {
+		errmsg := fmt.Sprintf("Error marshaling JSON: %v", err)
+		Logger.Error(errmsg)
+	}
+	err = json.Unmarshal(configBytes, &configMap)
+	if err != nil {
+		errmsg := fmt.Sprintf("Error unmarshaling JSON: %v", err)
+		Logger.Error(errmsg)
+	}
+	err = persistConf(configMap)
+	if err != nil {
+		errmsg := fmt.Sprintf("Error persisting JSON: %v", err)
+		Logger.Error(errmsg)
+	}
+	file, err = os.Open(confPath)
+	if err != nil {
+		errmsg := fmt.Sprintf("Error opening JSON: %v", err)
+		Logger.Error(errmsg)
+	}
+	decoder = json.NewDecoder(file)
+	err = decoder.Decode(&globalConfig)
+	if err != nil {
+		errmsg := fmt.Sprintf("Error decoding JSON: %v", err)
+		Logger.Error(errmsg)
+	}
 }
 
 // return the global conf var