Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get(self, request):
- token = request.GET.get('token')
- try:
- payload = jwt.decode(token, settings.SECRET_KEY, algorithms=['HS256'])
- user = User.objects.get(pk=payload['user_id'])
- user.is_active = True
- user.save()
- return Response({
- 'email': 'Successfully activated!'
- }, status=status.HTTP_200_OK)
- except jwt.ExpiredSignatureError:
- return Response({'error': 'Activation link has expired'}, status=status.HTTP_400_BAD_REQUEST)
- except jwt.DecodeError:
- return Response({'error': 'Invalid token'}, status=
Advertisement
Add Comment
Please, Sign In to add comment