feat: auth1 utils enm 修改阿里云发送短信引入方式
This commit is contained in:
parent
dbea38f82b
commit
446f705eb3
|
@ -10,7 +10,7 @@ from apps.auth1.errors import USERNAME_OR_PASSWORD_WRONG
|
||||||
from rest_framework_simplejwt.tokens import RefreshToken
|
from rest_framework_simplejwt.tokens import RefreshToken
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from apps.auth1.services import check_phone_code
|
from apps.auth1.services import check_phone_code
|
||||||
from apps.utils.sms import send_sms
|
|
||||||
from apps.utils.tools import rannum
|
from apps.utils.tools import rannum
|
||||||
from apps.utils.wxmp import wxmpClient
|
from apps.utils.wxmp import wxmpClient
|
||||||
from apps.utils.wx import wxClient
|
from apps.utils.wx import wxClient
|
||||||
|
@ -182,6 +182,7 @@ class SendCode(CreateAPIView):
|
||||||
|
|
||||||
短信验证码发送
|
短信验证码发送
|
||||||
"""
|
"""
|
||||||
|
from apps.utils.sms import send_sms
|
||||||
phone = request.data['phone']
|
phone = request.data['phone']
|
||||||
code = rannum(6)
|
code = rannum(6)
|
||||||
is_ok, _ = send_sms(phone, 505, {'code': code})
|
is_ok, _ = send_sms(phone, 505, {'code': code})
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from aliyunsdkcore.client import AcsClient
|
|
||||||
from aliyunsdkcore.request import CommonRequest
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
from server.settings import get_sysconfig
|
from server.settings import get_sysconfig
|
||||||
|
@ -12,6 +11,8 @@ myLogger = logging.getLogger('log')
|
||||||
|
|
||||||
@auto_log(name='阿里云短信', raise_exception=True, send_mail=True)
|
@auto_log(name='阿里云短信', raise_exception=True, send_mail=True)
|
||||||
def send_sms(phone: str, template_code: int, template_param: dict):
|
def send_sms(phone: str, template_code: int, template_param: dict):
|
||||||
|
from aliyunsdkcore.client import AcsClient
|
||||||
|
from aliyunsdkcore.request import CommonRequest
|
||||||
config = get_sysconfig()
|
config = get_sysconfig()
|
||||||
if config.get("sms", {}).get('enabled', False) is False:
|
if config.get("sms", {}).get('enabled', False) is False:
|
||||||
raise ParseError("短信发送功能未启用")
|
raise ParseError("短信发送功能未启用")
|
||||||
|
|
Loading…
Reference in New Issue