jira-7 email

This commit is contained in:
jain
2023-06-29 20:26:35 +05:30
parent 70c136dde4
commit c2713b8214
6 changed files with 23 additions and 30 deletions

View File

@ -141,7 +141,6 @@ class UserLogin(viewsets.ViewSet):
def login(self, request): def login(self, request):
username = request.data.get('username') username = request.data.get('username')
password = request.data.get('password') password = request.data.get('password')
print("username==>",username,'==>',password)
user = authenticate(request, username=username, password=password) user = authenticate(request, username=username, password=password)
try: try:
@ -162,7 +161,7 @@ class UserLogin(viewsets.ViewSet):
refresh = RefreshToken.for_user(user) refresh = RefreshToken.for_user(user)
access_token = str(refresh.access_token) access_token = str(refresh.access_token)
data = {"auth_token":access_token, "is_profile_complete": False, data = {"auth_token":access_token, "is_profile_complete": False,
"user_role": email_verified.user_type, "user_type": email_verified.user_type,
} }
is_verified = False is_verified = False
if email_verified: if email_verified:

View File

@ -8,7 +8,7 @@ from django.db import transaction
from django.contrib.auth.models import User from django.contrib.auth.models import User
"""Import Django app""" """Import Django app"""
from .models import Guardian from .models import Guardian
from account.models import UserProfile from account.models import UserProfile, UserEmailOtp
from base.messages import ERROR_CODE, SUCCESS_CODE from base.messages import ERROR_CODE, SUCCESS_CODE
from .utils import upload_image_to_alibaba from .utils import upload_image_to_alibaba
from junior.models import Junior from junior.models import Junior
@ -43,13 +43,12 @@ class UserSerializer(serializers.ModelSerializer):
except Exception as e: except Exception as e:
"""Error handling""" """Error handling"""
logging.error(e) logging.error(e)
raise serializers.ValidationError({"details":ERROR_CODE['2021']}) otp = UserEmailOtp.objects.filter(email=email).last()
otp_verified = False
def save(self, **kwargs): if otp and otp.is_verified:
"""save the data""" otp_verified = True
with transaction.atomic(): raise serializers.ValidationError({"details":ERROR_CODE['2021'], "otp_verified":otp_verified, "code": "400", "status":"failed",
instance = super().save(**kwargs) })
return instance
class CreateGuardianSerializer(serializers.ModelSerializer): class CreateGuardianSerializer(serializers.ModelSerializer):
"""Create guardian serializer""" """Create guardian serializer"""
@ -86,7 +85,7 @@ class CreateGuardianSerializer(serializers.ModelSerializer):
def create(self, validated_data): def create(self, validated_data):
"""Create guardian profile""" """Create guardian profile"""
phone_number = validated_data.pop('phone', None) phone_number = validated_data.get('phone', None)
guardian_data = Guardian.objects.filter(phone=phone_number) guardian_data = Guardian.objects.filter(phone=phone_number)
junior_data = Junior.objects.filter(phone=phone_number) junior_data = Junior.objects.filter(phone=phone_number)
if phone_number and (guardian_data or junior_data): if phone_number and (guardian_data or junior_data):

View File

@ -23,7 +23,7 @@ class SignupViewset(viewsets.ModelViewSet):
serializer.save() serializer.save()
"""Generate otp""" """Generate otp"""
otp = generate_otp() otp = generate_otp()
UserEmailOtp.objects.create(email=request.data['email'], otp=otp, user_type=request.data['user_type']) UserEmailOtp.objects.create(email=request.data['email'], otp=otp, user_type=str(request.data['user_type']))
"""Send email to the register user""" """Send email to the register user"""
send_otp_email(request.data['email'], otp) send_otp_email(request.data['email'], otp)
return custom_response(SUCCESS_CODE['3001'], {"email_otp": otp}, return custom_response(SUCCESS_CODE['3001'], {"email_otp": otp},

View File

@ -58,9 +58,8 @@ class CreateJuniorSerializer(serializers.ModelSerializer):
def create(self, validated_data): def create(self, validated_data):
"""Create junior profile""" """Create junior profile"""
image = validated_data.pop('image', None) image = validated_data.get('image', None)
phone_number = validated_data.pop('phone', None) phone_number = validated_data.get('phone', None)
print("phone_number====>",phone_number,'==>',type(phone_number))
guardian_data = Guardian.objects.filter(phone=phone_number) guardian_data = Guardian.objects.filter(phone=phone_number)
junior_data = Junior.objects.filter(phone=phone_number) junior_data = Junior.objects.filter(phone=phone_number)
if phone_number and (junior_data or guardian_data): if phone_number and (junior_data or guardian_data):

View File

@ -19,6 +19,6 @@ upstream web {
location /static { location /static {
autoindex on; autoindex on;
alias /usr/src/app/zod_bank/static/; alias /usr/src/app/static/;
} }
} }

View File

@ -172,15 +172,6 @@ CORS_ALLOW_HEADERS = (
https://docs.djangoproject.com/en/3.0/howto/static-files/""" https://docs.djangoproject.com/en/3.0/howto/static-files/"""
# Email settings For temporary use
# EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# EMAIL_HOST = 'smtp.gmail.com'
# EMAIL_PORT = 587
# EMAIL_USE_TLS = True
# EMAIL_HOST_USER = 'infozodbank@gmail.com'
# # Replace with your Gmail email password or App password
# EMAIL_HOST_PASSWORD = 'ghwdmznwwslvchga'
# EMAIL_BACKEND = os.getenv('EMAIL_BACKEND') # EMAIL_BACKEND = os.getenv('EMAIL_BACKEND')
# EMAIL_HOST = os.getenv('EMAIL_HOST') # EMAIL_HOST = os.getenv('EMAIL_HOST')
# EMAIL_PORT = os.getenv('EMAIL_PORT') # EMAIL_PORT = os.getenv('EMAIL_PORT')
@ -197,12 +188,17 @@ EMAIL_HOST_USER="apikey" # Replace with your Gmail email address
EMAIL_HOST_PASSWORD="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" EMAIL_HOST_PASSWORD="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"
EMAIL_FROM_ADDRESS="zodbank@yopmail.com" EMAIL_FROM_ADDRESS="zodbank@yopmail.com"
ALIYUN_OSS_ACCESS_KEY_ID = os.getenv('ALIYUN_OSS_ACCESS_KEY_ID') # ALIYUN_OSS_ACCESS_KEY_ID = os.getenv('ALIYUN_OSS_ACCESS_KEY_ID')
ALIYUN_OSS_ACCESS_KEY_SECRET = os.getenv('ALIYUN_OSS_ACCESS_KEY_SECRET') # ALIYUN_OSS_ACCESS_KEY_SECRET = os.getenv('ALIYUN_OSS_ACCESS_KEY_SECRET')
ALIYUN_OSS_BUCKET_NAME = os.getenv('ALIYUN_OSS_BUCKET_NAME') # ALIYUN_OSS_BUCKET_NAME = os.getenv('ALIYUN_OSS_BUCKET_NAME')
ALIYUN_OSS_ENDPOINT = os.getenv('ALIYUN_OSS_ENDPOINT') # ALIYUN_OSS_ENDPOINT = os.getenv('ALIYUN_OSS_ENDPOINT')
ALIYUN_OSS_REGION = os.getenv('ALIYUN_OSS_REGION') # ALIYUN_OSS_REGION = os.getenv('ALIYUN_OSS_REGION')
ALIYUN_OSS_ACCESS_KEY_ID="LTAI5t7w1gq1CswJtvxtEZTd"
ALIYUN_OSS_ACCESS_KEY_SECRET="6yknAFpP2gVMhCWAJwbAjCEw2eehpf"
ALIYUN_OSS_BUCKET_NAME="zod-dev"
ALIYUN_OSS_ENDPOINT="oss-me-central-1.aliyuncs.com"
ALIYUN_OSS_REGION="Global"
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATIC_ROOT = 'static' STATIC_ROOT = 'static'