From b509cae9479053bda05c40c0412536345b517f99 Mon Sep 17 00:00:00 2001 From: through-your-tears Date: Sun, 7 Apr 2024 09:44:11 +0300 Subject: [PATCH] =?UTF-8?q?=D0=91=D0=B0=D0=B3=20=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jwtauth/models.py | 6 ------ src/jwtauth/views.py | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/jwtauth/models.py b/src/jwtauth/models.py index c8be15e..62b4621 100644 --- a/src/jwtauth/models.py +++ b/src/jwtauth/models.py @@ -69,9 +69,3 @@ class Friend(models.Model): class QRCode(models.Model): qr_str = models.CharField(max_length=1024, default='', blank=True) user = models.OneToOneField(CustomUser, on_delete=models.CASCADE) - - def save( - self, force_insert=False, force_update=False, using=None, update_fields=None - ): - self.qr_str = encrypt(self.user.email) - diff --git a/src/jwtauth/views.py b/src/jwtauth/views.py index 7209bc8..a1f1a7c 100644 --- a/src/jwtauth/views.py +++ b/src/jwtauth/views.py @@ -13,6 +13,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from core.permissions import IsAuthorOrReadOnly +from crypto.services import encrypt from .models import CustomUser, RefreshToken from .repositories import RefreshTokenRepository, ProfileRepository, UserRepository, QRCodeRepository from .serializers import RegistrationSerializer, LoginSerializer, CustomUserSerializer, ProfileSerializer, QRCodeSerializer @@ -104,7 +105,7 @@ class RegistrationAPIView(APIView): serializer.is_valid(raise_exception=True) serializer.save() ProfileRepository.create(user=UserRepository.get(serializer.data['email'])) - QRCodeRepository.create(user=UserRepository.get(serializer.data['email'])) + QRCodeRepository.create(qr_str=encrypt(serializer.data['email']), user=UserRepository.get(serializer.data['email'])) return Response(serializer.data, status=status.HTTP_201_CREATED)