Browse Source

Net 822 (#2759)

* add extclient allowed ips to rac resp

* add gw peer public key

* fix static check

* add param for remote access client id

* don't decode body

* debug

* debug

* change user gws req to POST

* debug

* change api to GET

* send array for user gws if req came from mobile
Abhishek K 1 year ago
parent
commit
8bfd791135
1 changed files with 10 additions and 0 deletions
  1. 10 0
      pro/controllers/users.go

+ 10 - 0
pro/controllers/users.go

@@ -162,6 +162,7 @@ func getUserRemoteAccessGws(w http.ResponseWriter, r *http.Request) {
 			return
 			return
 		}
 		}
 	}
 	}
+	reqFromMobile := r.URL.Query().Get("from_mobile") == "true"
 	if req.RemoteAccessClientID == "" && remoteAccessClientID == "" {
 	if req.RemoteAccessClientID == "" && remoteAccessClientID == "" {
 		logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("remote access client id cannot be empty"), "badrequest"))
 		logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("remote access client id cannot be empty"), "badrequest"))
 		return
 		return
@@ -288,6 +289,15 @@ func getUserRemoteAccessGws(w http.ResponseWriter, r *http.Request) {
 			}
 			}
 		}
 		}
 	}
 	}
+	if reqFromMobile {
+		// send resp in array format
+		userGwsArr := []models.UserRemoteGws{}
+		for _, userGwI := range userGws {
+			userGwsArr = append(userGwsArr, userGwI...)
+		}
+		logic.ReturnSuccessResponseWithJson(w, r, userGwsArr, "fetched gateways for user"+username)
+		return
+	}
 	slog.Debug("returned user gws", "user", username, "gws", userGws)
 	slog.Debug("returned user gws", "user", username, "gws", userGws)
 	w.WriteHeader(http.StatusOK)
 	w.WriteHeader(http.StatusOK)
 	json.NewEncoder(w).Encode(userGws)
 	json.NewEncoder(w).Encode(userGws)