Commit 52a04f68 authored by Gladys Forte's avatar Gladys Forte

forgot password

parent 498f0503
...@@ -158,7 +158,7 @@ class ForgotPassword(APIView): ...@@ -158,7 +158,7 @@ class ForgotPassword(APIView):
created=date_now, created=date_now,
timeout_at=timeout_at timeout_at=timeout_at
).save() ).save()
url = f"{settings.FRONT_END_URL}/forgot-password/reset"\ url = f"{settings.FRONT_END_URL}/forgot-password/reset"\
f"?token={TOKEN}" f"?token={TOKEN}"
...@@ -190,10 +190,15 @@ class ValidateForgotPasswordResetToken(APIView): ...@@ -190,10 +190,15 @@ class ValidateForgotPasswordResetToken(APIView):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
token = request.data['token'] token = request.data['token']
date_now = datetime.now()
existingToken = AuthToken.objects.filter(token=token).first() existingToken = AuthToken.objects.filter(token=token).first()
if existingToken: if existingToken:
if not existingToken.is_active: if not existingToken.is_active:
raise Exception('Request is no longer active') raise Exception('Request is no longer active')
elif existingToken.timeout_at < date_now:
raise Exception('Token already expired')
return Response(data={ return Response(data={
"username": existingToken.user.username, "username": existingToken.user.username,
"email": existingToken.user.email "email": existingToken.user.email
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment