raise an error if duplicate key is present
This commit is contained in:
		
							parent
							
								
									5a6a19c661
								
							
						
					
					
						commit
						94aaef70a7
					
				|  | @ -185,6 +185,19 @@ func NewClient(db store.IStore) echo.HandlerFunc { | |||
| 				log.Error("Cannot verify wireguard public key: ", err) | ||||
| 				return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot verify Wireguard public key"}) | ||||
| 			} | ||||
| 			// check for duplicates
 | ||||
| 			clients, err := db.GetClients(false) | ||||
| 			if err != nil { | ||||
| 				log.Error("Cannot get clients for duplicate check") | ||||
| 				return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get clients for duplicate check"}) | ||||
| 			} | ||||
| 			for _, other := range clients { | ||||
| 				if other.Client.PublicKey == client.PublicKey { | ||||
| 					log.Error("Duplicate Public Key") | ||||
| 					return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Duplicate Public Key"}) | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 		} | ||||
| 
 | ||||
| 		if client.PresharedKey == "" { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue