Skip to content

Commit

Permalink
Merge pull request #1305 from GSA/notify-admin-1157
Browse files Browse the repository at this point in the history
debug messages for e2e test story
  • Loading branch information
heyitsmebev authored Aug 28, 2024
2 parents 6a2fae5 + d4c4bbd commit 3fd9af6
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions app/user/rest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import uuid
from urllib.parse import urlencode

Expand Down Expand Up @@ -53,7 +54,7 @@
post_verify_code_schema,
post_verify_webauthn_schema,
)
from app.utils import url_with_token, utc_now
from app.utils import hilite, url_with_token, utc_now
from notifications_utils.recipients import is_us_phone_number, use_numeric_sender

user_blueprint = Blueprint("user", __name__)
Expand Down Expand Up @@ -588,13 +589,27 @@ def get_user_login_gov_user():
return jsonify(data=result)


def debug_not_production(msg):
if os.getenv("NOTIFY_ENVIRONMENT") not in ["production"]:
current_app.logger.info(msg)


@user_blueprint.route("/email", methods=["POST"])
def fetch_user_by_email():
email = email_data_request_schema.load(request.get_json())

fetched_user = get_user_by_email(email["email"])
result = fetched_user.serialize()
return jsonify(data=result)
try:
debug_not_production(
hilite(f"enter fetch_user_by_email with {request.get_json()}")
)
email = email_data_request_schema.load(request.get_json())
debug_not_production(hilite(f"request schema loads {email}"))
fetched_user = get_user_by_email(email["email"])
debug_not_production(hilite(f"fetched user is {fetched_user}"))
result = fetched_user.serialize()
debug_not_production(hilite(f"result is serialized to {result}"))
return jsonify(data=result)
except Exception as e:
debug_not_production(hilite(f"Failed with {e}!!"))
raise e


# TODO: Deprecate this GET endpoint
Expand Down

0 comments on commit 3fd9af6

Please sign in to comment.