feat: auth1 utils enm 修改阿里云发送短信引入方式

This commit is contained in:
zty 2025-05-21 09:51:46 +08:00
parent dbea38f82b
commit 446f705eb3
2 changed files with 5 additions and 3 deletions

View File

@ -10,7 +10,7 @@ from apps.auth1.errors import USERNAME_OR_PASSWORD_WRONG
from rest_framework_simplejwt.tokens import RefreshToken
from django.core.cache import cache
from apps.auth1.services import check_phone_code
from apps.utils.sms import send_sms
from apps.utils.tools import rannum
from apps.utils.wxmp import wxmpClient
from apps.utils.wx import wxClient
@ -182,6 +182,7 @@ class SendCode(CreateAPIView):
短信验证码发送
"""
from apps.utils.sms import send_sms
phone = request.data['phone']
code = rannum(6)
is_ok, _ = send_sms(phone, 505, {'code': code})

View File

@ -1,5 +1,4 @@
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
import json
import logging
from server.settings import get_sysconfig
@ -12,6 +11,8 @@ myLogger = logging.getLogger('log')
@auto_log(name='阿里云短信', raise_exception=True, send_mail=True)
def send_sms(phone: str, template_code: int, template_param: dict):
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
config = get_sysconfig()
if config.get("sms", {}).get('enabled', False) is False:
raise ParseError("短信发送功能未启用")