mirror of
https://github.com/gravitl/netmaker.git
synced 2025-12-24 13:28:22 +08:00
check feature flags for auto join
This commit is contained in:
@@ -242,9 +242,10 @@ func SessionHandler(conn *websocket.Conn) {
|
||||
// CheckNetRegAndHostUpdate - run through networks and send a host update
|
||||
func CheckNetRegAndHostUpdate(key models.EnrollmentKey, h *models.Host, username string) {
|
||||
// publish host update through MQ
|
||||
featureFlags := logic.GetFeatureFlags()
|
||||
for _, netID := range key.Networks {
|
||||
if network, err := logic.GetNetwork(netID); err == nil {
|
||||
if network.AutoJoin == "false" {
|
||||
if featureFlags.EnableDeviceApproval && network.AutoJoin == "false" {
|
||||
if logic.DoesHostExistinTheNetworkAlready(h, models.NetworkID(netID)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -597,6 +597,10 @@ func createNetwork(w http.ResponseWriter, r *http.Request) {
|
||||
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
|
||||
return
|
||||
}
|
||||
featureFlags := logic.GetFeatureFlags()
|
||||
if !featureFlags.EnableDeviceApproval {
|
||||
network.AutoJoin = "true"
|
||||
}
|
||||
|
||||
if len(network.NetID) > 32 {
|
||||
err := errors.New("network name shouldn't exceed 32 characters")
|
||||
|
||||
@@ -650,7 +650,13 @@ func UpdateNetwork(currentNetwork *models.Network, newNetwork *models.Network) e
|
||||
if newNetwork.NetID != currentNetwork.NetID {
|
||||
return errors.New("failed to update network " + newNetwork.NetID + ", cannot change netid.")
|
||||
}
|
||||
currentNetwork.AutoJoin = newNetwork.AutoJoin
|
||||
featureFlags := GetFeatureFlags()
|
||||
if featureFlags.EnableDeviceApproval {
|
||||
currentNetwork.AutoJoin = newNetwork.AutoJoin
|
||||
} else {
|
||||
currentNetwork.AutoJoin = "true"
|
||||
}
|
||||
|
||||
currentNetwork.DefaultACL = newNetwork.DefaultACL
|
||||
currentNetwork.NameServers = newNetwork.NameServers
|
||||
data, err := json.Marshal(currentNetwork)
|
||||
|
||||
Reference in New Issue
Block a user