add POST get user by email endpoint

the existing endpoint is a GET, and so leaves email addresses in log
files.

we've got an existing POST find_users_by_partial_email, but not one that
matches on a whole email address.
This commit is contained in:
Leo Hemsted
2021-03-05 12:38:14 +00:00
parent 8e5f956009
commit e0234fecba
2 changed files with 51 additions and 0 deletions

View File

@@ -417,6 +417,19 @@ def set_permissions(user_id, service_id):
return jsonify({}), 204
@user_blueprint.route('/email', methods=['POST'])
def fetch_user_by_email():
email, errors = email_data_request_schema.load(request.get_json())
if errors:
raise InvalidRequest(message=errors, status_code=400)
fetched_user = get_user_by_email(email['email'])
result = fetched_user.serialize()
return jsonify(data=result)
# TODO: Deprecate this GET endpoint
@user_blueprint.route('/email', methods=['GET'])
def get_by_email():
email = request.args.get('email')