diff --git a/django_rest_passwordreset/views.py b/django_rest_passwordreset/views.py index a2a4480..14cd345 100644 --- a/django_rest_passwordreset/views.py +++ b/django_rest_passwordreset/views.py @@ -79,6 +79,10 @@ def post(self, request, *args, **kwargs): # find token reset_password_token = ResetPasswordToken.objects.filter(key=token).first() + if not reset_password_token: + # Check if token exists and raise a validation error for the serializer + # with a correct feedback + raise exceptions.ValidationError({'token': 'Invalid token'}) # change users password (if we got to this code it means that the user is_active) if reset_password_token.user.eligible_for_reset():