Skip to content

Commit d24dc7d

Browse files
felipesilvadvLuis Felipe Silva De Vidts
authored andcommitted
Improve feedback message
1 parent 70e00b6 commit d24dc7d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

django_rest_passwordreset/views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ def post(self, request, *args, **kwargs):
7979

8080
# find token
8181
reset_password_token = ResetPasswordToken.objects.filter(key=token).first()
82+
if not reset_password_token:
83+
# Check if token exists and raise a validation error for the serializer
84+
# with a correct feedback
85+
raise exceptions.ValidationError({'token': 'Invalid token'})
8286

8387
# change users password (if we got to this code it means that the user is_active)
8488
if reset_password_token.user.eligible_for_reset():

0 commit comments

Comments
 (0)