mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-27 17:14:55 +00:00
sonar issues
This commit is contained in:
@ -22,7 +22,7 @@ from junior.models import Junior
|
||||
from guardian.models import Guardian
|
||||
from account.models import UserDelete
|
||||
from base.messages import ERROR_CODE
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
# Define delete
|
||||
# user account condition,
|
||||
@ -228,3 +228,4 @@ def generate_code(value, user_id):
|
||||
return code
|
||||
|
||||
|
||||
OTP_EXPIRY = timezone.now() + timezone.timedelta(days=1)
|
||||
|
||||
@ -22,7 +22,7 @@ from django.conf import settings
|
||||
"""App Import"""
|
||||
from guardian.models import Guardian
|
||||
from junior.models import Junior
|
||||
from guardian.utils import upload_image_to_alibaba
|
||||
from guardian.utils import upload_image_to_alibaba, OTP_EXPIRY
|
||||
from account.models import UserDeviceDetails, UserPhoneOtp, UserEmailOtp, DefaultTaskImages, UserNotification
|
||||
from django.contrib.auth.models import User
|
||||
"""Account serializer"""
|
||||
@ -228,7 +228,7 @@ class ForgotPasswordAPIView(views.APIView):
|
||||
'verification_code': verification_code
|
||||
}
|
||||
)
|
||||
expiry = timezone.now() + timezone.timedelta(days=1)
|
||||
expiry = OTP_EXPIRY
|
||||
user_data, created = UserEmailOtp.objects.get_or_create(email=email)
|
||||
if created:
|
||||
user_data.expired_at = expiry
|
||||
@ -399,7 +399,7 @@ class ReSendEmailOtp(viewsets.ModelViewSet):
|
||||
def create(self, request, *args, **kwargs):
|
||||
otp = generate_otp()
|
||||
if User.objects.filter(email=request.data['email']):
|
||||
expiry = timezone.now() + timezone.timedelta(days=1)
|
||||
expiry = OTP_EXPIRY
|
||||
email_data, created = UserEmailOtp.objects.get_or_create(email=request.data['email'])
|
||||
if created:
|
||||
email_data.expired_at = expiry
|
||||
|
||||
@ -31,8 +31,7 @@ from .models import Guardian, JuniorTask
|
||||
from junior.models import Junior, JuniorPoints
|
||||
from account.models import UserEmailOtp, UserNotification
|
||||
from .tasks import generate_otp
|
||||
from account.utils import send_otp_email
|
||||
from account.utils import custom_response, custom_error_response
|
||||
from account.utils import custom_response, custom_error_response, OTP_EXPIRY, send_otp_email
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from base.constants import NUMBER
|
||||
from .utils import upload_image_to_alibaba
|
||||
@ -65,7 +64,7 @@ class SignupViewset(viewsets.ModelViewSet):
|
||||
"""Generate otp"""
|
||||
otp = generate_otp()
|
||||
# expire otp after 1 day
|
||||
expiry = timezone.now() + timezone.timedelta(days=1)
|
||||
expiry = OTP_EXPIRY
|
||||
# create user email otp object
|
||||
UserEmailOtp.objects.create(email=request.data['email'], otp=otp,
|
||||
user_type=str(request.data['user_type']), expired_at=expiry)
|
||||
|
||||
Reference in New Issue
Block a user