locust-cloud 1.11.2__py3-none-any.whl → 1.11.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
locust_cloud/auth.py CHANGED
@@ -96,11 +96,14 @@ def register_auth(environment: locust.env.Environment):
96
96
  session["challenge_session"] = credentials.get("challenge_session")
97
97
  session["username"] = username
98
98
  return redirect(url_for("locust_cloud_auth.password_reset"))
99
-
100
- if os.getenv("CUSTOMER_ID", "") and credentials["customer_id"] != os.getenv("CUSTOMER_ID", ""):
99
+ if os.getenv("CUSTOMER_ID", "") and credentials.get("customer_id") != os.getenv("CUSTOMER_ID", ""):
101
100
  session["auth_error"] = "Invalid login for this deployment"
102
101
  return redirect(url_for("locust.login"))
103
102
 
103
+ if not credentials.get("user_sub_id"):
104
+ session["auth_error"] = "Unknown error during authentication, check logs and/or contact support"
105
+ return redirect(url_for("locust.login"))
106
+
104
107
  response = redirect(url_for("locust.index"))
105
108
  response = set_credentials(username, credentials, response)
106
109
  login_user(AuthUser(credentials["user_sub_id"]))
@@ -221,10 +224,14 @@ def register_auth(environment: locust.env.Environment):
221
224
 
222
225
  @auth_blueprint.route("/resend-code")
223
226
  def resend_code():
227
+ if not session.get("username"):
228
+ session["auth_sign_up_error"] = "An unexpected error occured. Please try again."
229
+ return redirect(url_for("locust_cloud_auth.signup"))
230
+
224
231
  try:
225
232
  auth_response = requests.post(
226
233
  f"{environment.parsed_options.deployer_url}/auth/resend-confirmation",
227
- json={"username": session["username"]},
234
+ json={"username": session.get("username")},
228
235
  )
229
236
 
230
237
  auth_response.raise_for_status()
@@ -244,6 +251,9 @@ def register_auth(environment: locust.env.Environment):
244
251
  def confirm_signup():
245
252
  if not environment.parsed_options.allow_signup:
246
253
  return redirect(url_for("locust.login"))
254
+ if not session.get("user_sub_id"):
255
+ session["auth_sign_up_error"] = "An unexpected error occured. Please try again."
256
+ return redirect(url_for("locust_cloud_auth.signup"))
247
257
 
248
258
  session["auth_sign_up_error"] = ""
249
259
  confirmation_code = request.form.get("confirmation_code")