Skip to content

Commit

Permalink
removed multiple writePropos (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha authored Nov 2, 2023
1 parent 8459ca5 commit 8be0277
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
14 changes: 2 additions & 12 deletions wap/pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,17 @@ func propertiesHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
jsonErr := json.NewEncoder(w).Encode(response)
if jsonErr != nil {
http.Error(w, fmt.Sprintf("error building the response, %v", err), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("error building the response, %v", jsonErr), http.StatusInternalServerError)
return
}
return
} else if r.Method == "POST" {
ssid := r.FormValue("ssid")
password := r.FormValue("password")

err := config.WriteProperties(map[string]interface{}{
"ssid": ssid,
"password": password,
})
if err != nil {
log.Errorw("failed to write the properties", "err", err)
}

w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusCreated)
jsonErr := json.NewEncoder(w).Encode(map[string]interface{}{"success": true})
if jsonErr != nil {
http.Error(w, fmt.Sprintf("error building the response, %v", err), http.StatusInternalServerError)
http.Error(w, fmt.Sprintf("error building the response, %v", jsonErr), http.StatusInternalServerError)
return
}
}
Expand Down
10 changes: 0 additions & 10 deletions wap/pkg/wifi/wifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ func connectLinux(ctx context.Context, creds Credentials) error {
log.Info("Deleting FxBlox as connectToNetwork was successful")
DeleteConnection(ctx, "FxBlox")

// Save connection properties
if err := config.WriteProperties(map[string]interface{}{
"ssid": creds.SSID,
"password": creds.Password,
"connection": connectionName,
"country_code": creds.CountryCode,
}); err != nil {
log.Warnf("Couldn't write the properties file: %v", err)
}

return nil
}

Expand Down

0 comments on commit 8be0277

Please sign in to comment.