summaryrefslogtreecommitdiff
path: root/opendc/api/v2/users/endpoint.py
diff options
context:
space:
mode:
Diffstat (limited to 'opendc/api/v2/users/endpoint.py')
-rw-r--r--opendc/api/v2/users/endpoint.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/opendc/api/v2/users/endpoint.py b/opendc/api/v2/users/endpoint.py
index abd54f27..83949fcf 100644
--- a/opendc/api/v2/users/endpoint.py
+++ b/opendc/api/v2/users/endpoint.py
@@ -1,33 +1,25 @@
from opendc.models.user import User
from opendc.util import exceptions
+from opendc.util.database import fetch_one
from opendc.util.rest import Response
def GET(request):
"""Search for a User using their email address."""
- # Make sure required parameters are there
-
try:
request.check_required_parameters(
query={
'email': 'string'
}
)
-
except exceptions.ParameterError as e:
return Response(400, e.message)
- # Instantiate and read a User from the database
-
- user = User.from_email(request.params_query['email'])
-
- # Make sure this User exists in the database
-
- if not user.exists():
- return Response(404, '{} not found'.format(user))
+ user = fetch_one({'email': request.params_query['email']}, 'users')
- # Return this User
+ if user is not None:
+ return Response(404, f'User with email {request.params_query["email"]} not found')
return Response(
200,