Skip to content

Commit

Permalink
🔢 Merge pull request #123 from Sachin-chaurasiya/responses
Browse files Browse the repository at this point in the history
🔢  changed return response of Registerview to throw valid error message and added validation for email id
  • Loading branch information
PraveenMalethia authored May 15, 2021
2 parents 098d82d + a642545 commit b39ed94
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def post(self, request):
messages['errors'].append('Email can\'t be empty')
if password == None:
messages['errors'].append('Password can\'t be empty')
if User.objects.filter(email=email).exists():
messages['errors'].append("Account already exists with this email id.")
if len(messages['errors']) > 0:
return Response(messages=messages,status=status.HTTP_400_BAD_REQUEST)
return Response({"detail":messages['errors']},status=status.HTTP_400_BAD_REQUEST)
try:
user = User.objects.create(
username=username,
Expand Down

0 comments on commit b39ed94

Please sign in to comment.