I do get an email with a verification link - but when i follow the link it keeps throwing the 'Invalid Token'
class VerifyEmail(views.APIView):
serializer_class = EmailVerificationSerializer
token_param_config = openapi.Parameter('token',in_ = openapi.IN_QUERY, description='Description', type = openapi.TYPE_STRING)
@swagger_auto_schema(manual_parameters=[token_param_config])
def get(self,request):
token = request.GET.get('token')
try:
payload = jwt.decode(token,settings.SECRET_KEY)
user = User.objects.get(id=payload['user_id'])
if not user.is_verified:
user.is_verified = True
user.save()
return Response({'email':'Successfully activated'},status=status.HTTP_200_OK)
except jwt.ExpiredSignatureError as indentifier:
return Response({'error':'Activation Expired'},status=status.HTTP_400_BAD_REQUEST)
except jwt.exceptions.DecodeError as indentifier:
return Response({'error':'Invalid Token'},status=status.HTTP_400_BAD_REQUEST)