mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
changing validation
This commit is contained in:
@@ -563,10 +563,10 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
if servercfg.IsDNSMode() {
|
||||
err = logic.SetDNS()
|
||||
logic.SetDNS()
|
||||
}
|
||||
|
||||
logger.Log(1, r.Header.Get("user"), "updated node", node.MacAddress, "on network", node.Network)
|
||||
logger.Log(1, r.Header.Get("user"), "updated node", node.ID, "on network", node.Network)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(newNode)
|
||||
|
||||
|
@@ -159,7 +159,7 @@ func UpdateNode(currentNode *models.Node, newNode *models.Node) error {
|
||||
return database.Insert(newNode.ID, string(data), database.NODES_TABLE_NAME)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf("failed to update node " + newNode.MacAddress + ", cannot change macaddress.")
|
||||
return fmt.Errorf("failed to update node " + currentNode.ID + ", cannot change ID.")
|
||||
}
|
||||
|
||||
// IsNodeIDUnique - checks if node id is unique
|
||||
@@ -175,8 +175,10 @@ func ValidateNode(node *models.Node, isUpdate bool) error {
|
||||
if isUpdate {
|
||||
return true
|
||||
}
|
||||
unique, _ := isMacAddressUnique(node.MacAddress, node.Network)
|
||||
|
||||
var unique = true
|
||||
if !(node.MacAddress == "") {
|
||||
unique, _ = isMacAddressUnique(node.MacAddress, node.Network)
|
||||
}
|
||||
isFieldUnique, _ := IsNodeIDUnique(node)
|
||||
return isFieldUnique && unique
|
||||
})
|
||||
|
@@ -21,7 +21,7 @@ import (
|
||||
// SetJWT func will used to create the JWT while signing in and signing out
|
||||
func SetJWT(client nodepb.NodeServiceClient, network string) (context.Context, error) {
|
||||
home := ncutils.GetNetclientPathSpecific()
|
||||
tokentext, err := ncutils.GetFileWithRetry(home+"nettoken-"+network, 1)
|
||||
tokentext, err := os.ReadFile(home + "nettoken-" + network)
|
||||
if err != nil {
|
||||
err = AutoLogin(client, network)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user