mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 01:55:21 +00:00
jira-7 email
This commit is contained in:
@ -141,7 +141,6 @@ class UserLogin(viewsets.ViewSet):
|
||||
def login(self, request):
|
||||
username = request.data.get('username')
|
||||
password = request.data.get('password')
|
||||
print("username==>",username,'==>',password)
|
||||
user = authenticate(request, username=username, password=password)
|
||||
|
||||
try:
|
||||
@ -162,7 +161,7 @@ class UserLogin(viewsets.ViewSet):
|
||||
refresh = RefreshToken.for_user(user)
|
||||
access_token = str(refresh.access_token)
|
||||
data = {"auth_token":access_token, "is_profile_complete": False,
|
||||
"user_role": email_verified.user_type,
|
||||
"user_type": email_verified.user_type,
|
||||
}
|
||||
is_verified = False
|
||||
if email_verified:
|
||||
|
@ -8,7 +8,7 @@ from django.db import transaction
|
||||
from django.contrib.auth.models import User
|
||||
"""Import Django app"""
|
||||
from .models import Guardian
|
||||
from account.models import UserProfile
|
||||
from account.models import UserProfile, UserEmailOtp
|
||||
from base.messages import ERROR_CODE, SUCCESS_CODE
|
||||
from .utils import upload_image_to_alibaba
|
||||
from junior.models import Junior
|
||||
@ -43,13 +43,12 @@ class UserSerializer(serializers.ModelSerializer):
|
||||
except Exception as e:
|
||||
"""Error handling"""
|
||||
logging.error(e)
|
||||
raise serializers.ValidationError({"details":ERROR_CODE['2021']})
|
||||
|
||||
def save(self, **kwargs):
|
||||
"""save the data"""
|
||||
with transaction.atomic():
|
||||
instance = super().save(**kwargs)
|
||||
return instance
|
||||
otp = UserEmailOtp.objects.filter(email=email).last()
|
||||
otp_verified = False
|
||||
if otp and otp.is_verified:
|
||||
otp_verified = True
|
||||
raise serializers.ValidationError({"details":ERROR_CODE['2021'], "otp_verified":otp_verified, "code": "400", "status":"failed",
|
||||
})
|
||||
|
||||
class CreateGuardianSerializer(serializers.ModelSerializer):
|
||||
"""Create guardian serializer"""
|
||||
@ -86,7 +85,7 @@ class CreateGuardianSerializer(serializers.ModelSerializer):
|
||||
|
||||
def create(self, validated_data):
|
||||
"""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)
|
||||
junior_data = Junior.objects.filter(phone=phone_number)
|
||||
if phone_number and (guardian_data or junior_data):
|
||||
|
@ -23,7 +23,7 @@ class SignupViewset(viewsets.ModelViewSet):
|
||||
serializer.save()
|
||||
"""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_otp_email(request.data['email'], otp)
|
||||
return custom_response(SUCCESS_CODE['3001'], {"email_otp": otp},
|
||||
|
@ -58,9 +58,8 @@ class CreateJuniorSerializer(serializers.ModelSerializer):
|
||||
|
||||
def create(self, validated_data):
|
||||
"""Create junior profile"""
|
||||
image = validated_data.pop('image', None)
|
||||
phone_number = validated_data.pop('phone', None)
|
||||
print("phone_number====>",phone_number,'==>',type(phone_number))
|
||||
image = validated_data.get('image', None)
|
||||
phone_number = validated_data.get('phone', None)
|
||||
guardian_data = Guardian.objects.filter(phone=phone_number)
|
||||
junior_data = Junior.objects.filter(phone=phone_number)
|
||||
if phone_number and (junior_data or guardian_data):
|
||||
|
@ -19,6 +19,6 @@ upstream web {
|
||||
|
||||
location /static {
|
||||
autoindex on;
|
||||
alias /usr/src/app/zod_bank/static/;
|
||||
alias /usr/src/app/static/;
|
||||
}
|
||||
}
|
||||
|
@ -172,15 +172,6 @@ CORS_ALLOW_HEADERS = (
|
||||
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_HOST = os.getenv('EMAIL_HOST')
|
||||
# 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_FROM_ADDRESS="zodbank@yopmail.com"
|
||||
|
||||
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_BUCKET_NAME = os.getenv('ALIYUN_OSS_BUCKET_NAME')
|
||||
ALIYUN_OSS_ENDPOINT = os.getenv('ALIYUN_OSS_ENDPOINT')
|
||||
ALIYUN_OSS_REGION = os.getenv('ALIYUN_OSS_REGION')
|
||||
# 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_BUCKET_NAME = os.getenv('ALIYUN_OSS_BUCKET_NAME')
|
||||
# ALIYUN_OSS_ENDPOINT = os.getenv('ALIYUN_OSS_ENDPOINT')
|
||||
# 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_ROOT = 'static'
|
||||
|
Reference in New Issue
Block a user