Skip to content

Commit

Permalink
fix ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
asennoussi committed Aug 1, 2023
1 parent 9985816 commit 2425675
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class PasswordResetView(auth_views.PasswordResetView):

def form_valid(self, form):
response = super().form_valid(form)
if self.request.is_ajax():
if self.request.headers.get('x-requested-with') == 'XMLHttpRequest':
return JsonResponse({'status': 'ok', 'message': "If the email address exists in our database, you'll receive password reset instructions shortly."}, status=200)
else:
return response

def form_invalid(self, form):
response = super().form_invalid(form)
if self.request.is_ajax():
if self.request.headers.get('x-requested-with') == 'XMLHttpRequest':
return JsonResponse({'status': 'error', 'errors': form.errors}, status=400)
else:
return response
Expand Down

0 comments on commit 2425675

Please sign in to comment.