diff --git a/client/src/pages/newInstall/newInstall.jsx b/client/src/pages/newInstall/newInstall.jsx index 25d0a1c..72bfd1a 100644 --- a/client/src/pages/newInstall/newInstall.jsx +++ b/client/src/pages/newInstall/newInstall.jsx @@ -18,6 +18,7 @@ import LogsInModal from '../../components/logsInModal'; import { CosmosCheckbox, CosmosInputPassword, CosmosInputText, CosmosSelect } from '../config/users/formShortcuts'; import AnimateButton from '../../components/@extended/AnimateButton'; import { Box } from '@mui/system'; +import { pull } from 'lodash'; // ================================|| LOGIN ||================================ // const NewInstall = () => { @@ -27,6 +28,7 @@ const NewInstall = () => { let [hostname, setHostname] = useState(''); const [databaseEnable, setDatabaseEnable] = useState(true); const [pullRequest, setPullRequest] = useState(null); + const [pullRequestOnSuccess, setPullRequestOnSuccess] = useState(null); const refreshStatus = async () => { try { @@ -121,6 +123,9 @@ const NewInstall = () => { }} onSubmit={async (values, { setErrors, setStatus, setSubmitting }) => { setSubmitting(true); + const submittingPromise = new Promise((resolve, reject) => { + setPullRequestOnSuccess(() => resolve); + }); setPullRequest(() => ((cb) => { API.newInstall({ @@ -129,6 +134,8 @@ const NewInstall = () => { MongoDB: values.MongoDB, }, cb) })); + + return submittingPromise; }}> {(formik) => (
@@ -141,6 +148,13 @@ const NewInstall = () => { } formik.setStatus({ success: true }); formik.setSubmitting(false); + pullRequestOnSuccess(); + }} + OnError={(error) => { + formik.setStatus({ success: false }); + formik.setErrors({ submit: error.message }); + formik.setSubmitting(false); + pullRequestOnSuccess(); }} /> diff --git a/package.json b/package.json index 95aca5c..2a4032f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.5.5", + "version": "0.5.6", "description": "", "main": "test-server.js", "bugs": { diff --git a/src/proxy/shield.go b/src/proxy/shield.go index 1fe9bf9..d454360 100644 --- a/src/proxy/shield.go +++ b/src/proxy/shield.go @@ -7,6 +7,7 @@ import ( "net/http" "fmt" "net" + "os" "math" "strconv" ) @@ -233,8 +234,16 @@ func calculateLowestExhaustedPercentage(policy utils.SmartShieldPolicy, userCons } func GetClientID(r *http.Request) string { - ip, _, _ := net.SplitHostPort(r.RemoteAddr) - return ip + // when using Docker we need to get the real IP + if os.Getenv("HOSTNAME") != "" { + ip, _, _ := net.SplitHostPort(r.Header.Get("x-forwarded-for")) + utils.Debug("SmartShield: Getting client ID " + ip) + return ip + } else { + ip, _, _ := net.SplitHostPort(r.RemoteAddr) + utils.Debug("SmartShield: Getting client ID " + ip) + return ip + } } func isPrivileged(req *http.Request, policy utils.SmartShieldPolicy) bool {