diff --git a/core/maingate.go b/core/maingate.go index d6920bc..b759347 100644 --- a/core/maingate.go +++ b/core/maingate.go @@ -505,17 +505,20 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu } }() - apitoken := r.Header.Get("MG-X-API-TOKEN") - if len(apitoken) == 0 { - logger.Println("MG-X-API-TOKEN is missing") - w.WriteHeader(http.StatusBadRequest) - return + if !*noauth { + apitoken := r.Header.Get("MG-X-API-TOKEN") + if len(apitoken) == 0 { + logger.Println("MG-X-API-TOKEN is missing") + w.WriteHeader(http.StatusBadRequest) + return + } + + apitokenObj, _ := primitive.ObjectIDFromHex(apitoken) + if mg.service().isValidToken(apitokenObj) { + convertedConfig["divisions"] = mg.service().Divisions + } } - apitokenObj, _ := primitive.ObjectIDFromHex(apitoken) - if mg.service().isValidToken(apitokenObj) { - convertedConfig["divisions"] = mg.service().Divisions - } enc := json.NewEncoder(w) enc.Encode(convertedConfig) })