|
@@ -26,7 +26,7 @@ from ratelimit.decorators import ratelimit
|
|
|
|
|
|
from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN
|
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
|
-from Model.models import Device_User, Role, SysMsgModel, UidPushModel
|
|
|
+from Model.models import Device_User, Role, SysMsgModel, UidPushModel, UidSetModel
|
|
|
from Object.AWS.SesClassObject import SesClassObject
|
|
|
from Object.AliSmsObject import AliSmsObject
|
|
|
from Object.RedisObject import RedisObject
|
|
@@ -561,6 +561,7 @@ class v2authCodeView(TemplateView):
|
|
|
email = request_dict.get('email', None)
|
|
|
phone = request_dict.get('phone', None)
|
|
|
country_code = request_dict.get('country_code', None)
|
|
|
+ sign_name = request_dict.get('sign_name', None)
|
|
|
if email is not None:
|
|
|
email = email.strip()
|
|
|
# 阿里云的发送邮箱的调用方法
|
|
@@ -570,10 +571,10 @@ class v2authCodeView(TemplateView):
|
|
|
elif phone is not None:
|
|
|
phone = phone.strip()
|
|
|
if country_code is None:
|
|
|
- return self.phoneCode(phone, response)
|
|
|
+ return self.phoneCode(phone, response, sign_name)
|
|
|
else:
|
|
|
country_code = str(country_code.strip())
|
|
|
- return self.phoneCodeV2(country_code, phone, response)
|
|
|
+ return self.phoneCodeV2(country_code, phone, response, sign_name)
|
|
|
else:
|
|
|
return response.json(444)
|
|
|
|
|
@@ -650,7 +651,7 @@ class v2authCodeView(TemplateView):
|
|
|
return response.json(10, 'error')
|
|
|
return response.json(0)
|
|
|
|
|
|
- def phoneCode(self, phone, response):
|
|
|
+ def phoneCode(self, phone, response, sign_name):
|
|
|
dataValid = DataValid()
|
|
|
if dataValid.mobile_validate(phone) is not True:
|
|
|
return response.json(107)
|
|
@@ -668,7 +669,11 @@ class v2authCodeView(TemplateView):
|
|
|
identifyingCode = RandomStr(6, True)
|
|
|
# 发送手机验证码
|
|
|
aliSms = AliSmsObject()
|
|
|
- res = aliSms.send_code_sms(phone=phone, code=identifyingCode, sign_name='Ansjer',
|
|
|
+ if sign_name == 'zosi':
|
|
|
+ sign_ms = '周视'
|
|
|
+ else:
|
|
|
+ sign_ms = 'Ansjer'
|
|
|
+ res = aliSms.send_code_sms(phone=phone, code=identifyingCode, sign_name=sign_ms,
|
|
|
temp_msg='SMS_151600991')
|
|
|
print(res)
|
|
|
if res["Code"] == "OK":
|
|
@@ -680,7 +685,7 @@ class v2authCodeView(TemplateView):
|
|
|
else:
|
|
|
return response.json(10, res["Message"])
|
|
|
|
|
|
- def phoneCodeV2(self, country_code, phone, response):
|
|
|
+ def phoneCodeV2(self, country_code, phone, response, sign_name):
|
|
|
dataValid = DataValid()
|
|
|
if dataValid.mobile_validate(phone) is not True:
|
|
|
return response.json(107)
|
|
@@ -696,18 +701,29 @@ class v2authCodeView(TemplateView):
|
|
|
if user_qs.exists() or phone_qs.exists():
|
|
|
return response.json(101)
|
|
|
identifyingCode = RandomStr(6, True)
|
|
|
+ # 短信签名
|
|
|
+ # sign_name_dict = {
|
|
|
+ # 'ansjer':'Ansjer',
|
|
|
+ # 'zosi':'周视'
|
|
|
+ # }
|
|
|
+ sign_ms = ''
|
|
|
if country_code == '86':
|
|
|
# 国内短信推送模板
|
|
|
temp_msg = 'SMS_151600991'
|
|
|
rec_phone = phone
|
|
|
+ if sign_name == 'zosi':
|
|
|
+ sign_ms = '周视'
|
|
|
+ else:
|
|
|
+ sign_ms = 'Ansjer'
|
|
|
else:
|
|
|
# 国际短信推送模板
|
|
|
temp_msg = 'SMS_172165867'
|
|
|
rec_phone = country_code + phone
|
|
|
- # if ph
|
|
|
+ sign_ms = 'Ansjer'
|
|
|
+
|
|
|
# 发送手机验证码
|
|
|
aliSms = AliSmsObject()
|
|
|
- res = aliSms.send_code_sms(phone=rec_phone, code=identifyingCode, sign_name='Ansjer',
|
|
|
+ res = aliSms.send_code_sms(phone=rec_phone, code=identifyingCode, sign_name=sign_ms,
|
|
|
temp_msg=temp_msg)
|
|
|
print(res)
|
|
|
if res["Code"] == "OK":
|
|
@@ -893,18 +909,19 @@ class v2forgetPwdCodeView(TemplateView):
|
|
|
phone = request_dict.get('phone', None)
|
|
|
email = request_dict.get('email', None)
|
|
|
country_code = request_dict.get('country_code', None)
|
|
|
+ sign_name = request_dict.get('sign_name', None)
|
|
|
if phone is not None:
|
|
|
phone = phone.strip()
|
|
|
if country_code is None:
|
|
|
- return self.do_send_phone_code(phone, response)
|
|
|
+ return self.do_send_phone_code(phone, response,sign_name)
|
|
|
else:
|
|
|
- return self.do_v2_send_phone_code(country_code, phone, response)
|
|
|
+ return self.do_v2_send_phone_code(country_code, phone, response,sign_name)
|
|
|
elif email is not None:
|
|
|
return self.do_send_email_code(email, response)
|
|
|
else:
|
|
|
return response.json(444, 'phone')
|
|
|
|
|
|
- def do_send_phone_code(self, phone, response):
|
|
|
+ def do_send_phone_code(self, phone, response,sign_name):
|
|
|
data_valid = DataValid()
|
|
|
if data_valid.mobile_validate(phone) is not True:
|
|
|
return response.json(100)
|
|
@@ -921,8 +938,12 @@ class v2forgetPwdCodeView(TemplateView):
|
|
|
# if resetCode is True:
|
|
|
# return response.json(120)
|
|
|
resetCode = RandomStr(6, True)
|
|
|
+ if sign_name == 'zosi':
|
|
|
+ sign_ms = '周视'
|
|
|
+ else:
|
|
|
+ sign_ms = 'Ansjer'
|
|
|
aliSms = AliSmsObject()
|
|
|
- res = aliSms.send_code_sms(phone=phone, code=resetCode, sign_name='Ansjer',
|
|
|
+ res = aliSms.send_code_sms(phone=phone, code=resetCode, sign_name=sign_ms,
|
|
|
temp_msg='SMS_151675019')
|
|
|
if res["Code"] == "OK":
|
|
|
if not reds.set_data(key=reds_key, val=resetCode, expire=300):
|
|
@@ -931,7 +952,7 @@ class v2forgetPwdCodeView(TemplateView):
|
|
|
else:
|
|
|
return response.json(10, res["Message"])
|
|
|
|
|
|
- def do_v2_send_phone_code(self,country_code, phone, response):
|
|
|
+ def do_v2_send_phone_code(self, country_code, phone, response,sign_name):
|
|
|
data_valid = DataValid()
|
|
|
if data_valid.mobile_validate(phone) is not True:
|
|
|
return response.json(100)
|
|
@@ -952,10 +973,16 @@ class v2forgetPwdCodeView(TemplateView):
|
|
|
if country_code == '86':
|
|
|
rec_phone = phone
|
|
|
temp_msg = 'SMS_151675019'
|
|
|
+ if sign_name == 'zosi':
|
|
|
+ sign_ms = '周视'
|
|
|
+ else:
|
|
|
+ sign_ms = 'Ansjer'
|
|
|
else:
|
|
|
temp_msg = 'SMS_172200051'
|
|
|
- rec_phone = str(country_code)+str(phone)
|
|
|
- res = aliSms.send_code_sms(phone=rec_phone, code=resetCode, sign_name='Ansjer',
|
|
|
+ rec_phone = str(country_code) + str(phone)
|
|
|
+ sign_ms = 'Ansjer'
|
|
|
+
|
|
|
+ res = aliSms.send_code_sms(phone=rec_phone, code=resetCode, sign_name=sign_ms,
|
|
|
temp_msg=temp_msg)
|
|
|
if res["Code"] == "OK":
|
|
|
if not reds.set_data(key=reds_key, val=resetCode, expire=300):
|
|
@@ -1230,9 +1257,16 @@ class InitInfoView(View):
|
|
|
|
|
|
# 初始化设备token
|
|
|
def init_uid(self, request_dict, userID, response):
|
|
|
- # token_val = request_dict.get('token_val', None)
|
|
|
- # m_code = request_dict.get('m_code', None)
|
|
|
+ # 未读的系统消息
|
|
|
sm_count = SysMsgModel.objects.filter(userID_id=userID, status=0).count()
|
|
|
+
|
|
|
+ token_val = request_dict.get('token_val', None)
|
|
|
+ m_code = request_dict.get('m_code', None)
|
|
|
+ push_type = request_dict.get('push_type', None)
|
|
|
+ appBundleId = request_dict.get('appBundleId', None)
|
|
|
+ if all([token_val, push_type, appBundleId]):
|
|
|
+ UidPushModel.objects.filter(userID_id=userID, m_code=m_code). \
|
|
|
+ update(token_val=token_val, push_type=push_type)
|
|
|
res = {
|
|
|
'usmsg': sm_count
|
|
|
}
|