mirror of https://github.com/jumpserver/jumpserver
fix: 修复短信问题
parent
fa81652de5
commit
58a10778cd
|
@ -71,7 +71,7 @@ sms_failed_msg = _(
|
||||||
"(The account will be temporarily locked for {block_time} minutes)"
|
"(The account will be temporarily locked for {block_time} minutes)"
|
||||||
)
|
)
|
||||||
mfa_type_failed_msg = _(
|
mfa_type_failed_msg = _(
|
||||||
"The MFA type({mfa_type}) is not supported"
|
"The MFA type({mfa_type}) is not supported, "
|
||||||
"You can also try {times_try} times "
|
"You can also try {times_try} times "
|
||||||
"(The account will be temporarily locked for {block_time} minutes)"
|
"(The account will be temporarily locked for {block_time} minutes)"
|
||||||
)
|
)
|
||||||
|
|
|
@ -52,10 +52,13 @@ class VerifyCodeUtil:
|
||||||
ttl = self.ttl()
|
ttl = self.ttl()
|
||||||
if ttl > 0:
|
if ttl > 0:
|
||||||
raise CodeSendTooFrequently(ttl)
|
raise CodeSendTooFrequently(ttl)
|
||||||
|
try:
|
||||||
self.generate()
|
self.generate()
|
||||||
self.save()
|
self.save()
|
||||||
self.send()
|
self.send()
|
||||||
|
except JMSException:
|
||||||
|
self.clear()
|
||||||
|
raise
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
code = ''.join(random.sample('0123456789', 4))
|
code = ''.join(random.sample('0123456789', 4))
|
||||||
|
|
|
@ -19,19 +19,25 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group" style="display: flex">
|
||||||
<input type="text" class="form-control" name="code" placeholder="" required="" autofocus="autofocus">
|
|
||||||
<span class="help-block">
|
|
||||||
{% trans 'Please enter the verification code' %}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<button id='send-sms-verify-code' class="btn btn-primary full-width m-b" onclick="sendSMSVerifyCode()" style="display: none">{% trans 'Send verification code' %}</button>
|
|
||||||
<button type="submit" class="btn btn-primary block full-width m-b">{% trans 'Next' %}</button>
|
|
||||||
|
|
||||||
|
<input id="mfa-code" required type="text" class="form-control" name="code" placeholder="{% trans 'Please enter the verification code' %}" autofocus="autofocus">
|
||||||
|
<button id='send-sms-verify-code' type="button" class="btn btn-info full-width m-b" onclick="sendSMSVerifyCode()" style="width: 150px!important;">{% trans 'Send verification code' %}</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id='submit_button' type="submit" class="btn btn-primary block full-width m-b">{% trans 'Next' %}</button>
|
||||||
<div>
|
<div>
|
||||||
<small>{% trans "Can't provide security? Please contact the administrator!" %}</small>
|
<small>{% trans "Can't provide security? Please contact the administrator!" %}</small>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<style type="text/css">
|
||||||
|
.disabledBtn {
|
||||||
|
background: #e6e4e4!important;
|
||||||
|
border-color: #d8d5d5!important;
|
||||||
|
color: #949191!important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var methodSelect = document.getElementById('verify-method-select');
|
var methodSelect = document.getElementById('verify-method-select');
|
||||||
|
@ -44,19 +50,35 @@
|
||||||
|
|
||||||
if (type == "sms") {
|
if (type == "sms") {
|
||||||
currentBtn.style.display = "block";
|
currentBtn.style.display = "block";
|
||||||
|
currentBtn.disabled = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
currentBtn.style.display = "none";
|
currentBtn.style.display = "none";
|
||||||
|
currentBtn.disabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendSMSVerifyCode(){
|
function sendSMSVerifyCode(){
|
||||||
|
var currentBtn = document.getElementById('send-sms-verify-code');
|
||||||
|
var time = 60
|
||||||
var url = "{% url 'api-auth:sms-verify-code-send' %}";
|
var url = "{% url 'api-auth:sms-verify-code-send' %}";
|
||||||
requestApi({
|
requestApi({
|
||||||
url: url,
|
url: url,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
alert('验证码已发送');
|
currentBtn.innerHTML = `{% trans 'Wait: ' %} ${time}`;
|
||||||
|
currentBtn.disabled = true
|
||||||
|
currentBtn.classList.add("disabledBtn" )
|
||||||
|
var TimeInterval = setInterval(()=>{
|
||||||
|
--time
|
||||||
|
currentBtn.innerHTML = `{% trans 'Wait: ' %} ${time}`;
|
||||||
|
if(time === 0) {
|
||||||
|
currentBtn.innerHTML = "{% trans 'Send verification code' %}"
|
||||||
|
currentBtn.disabled = false
|
||||||
|
currentBtn.classList.remove("disabledBtn")
|
||||||
|
clearInterval(TimeInterval)
|
||||||
|
}
|
||||||
|
},1000)
|
||||||
|
alert("{% trans 'The verification code has been sent' %}");
|
||||||
},
|
},
|
||||||
error: function (text, data) {
|
error: function (text, data) {
|
||||||
alert(data.detail)
|
alert(data.detail)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class UserLoginOtpView(mixins.AuthMixin, FormView):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exception()
|
traceback.print_exception(e)
|
||||||
return redirect_to_guard_view()
|
return redirect_to_guard_view()
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
|
@ -1568,16 +1568,16 @@ msgid ""
|
||||||
"SMS verify code invalid,You can also try {times_try} times (The account will "
|
"SMS verify code invalid,You can also try {times_try} times (The account will "
|
||||||
"be temporarily locked for {block_time} minutes)"
|
"be temporarily locked for {block_time} minutes)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"短信验证码不正确,或者服务器端时间不对。 您还可以尝试 {times_try} 次(账号将"
|
"短信验证码不正确。 您还可以尝试 {times_try} 次(账号将被临时 锁定 "
|
||||||
"被临时 锁定 {block_time} 分钟)"
|
"{block_time} 分钟)"
|
||||||
|
|
||||||
#: authentication/errors.py:74
|
#: authentication/errors.py:74
|
||||||
#, python-brace-format
|
#, python-brace-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"The MFA type({mfa_type}) is not supportedYou can also try {times_try} times "
|
"The MFA type({mfa_type}) is not supported, You can also try {times_try} "
|
||||||
"(The account will be temporarily locked for {block_time} minutes)"
|
"times (The account will be temporarily locked for {block_time} minutes)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"该 ({mfa_type}) MFA 类型不支持。 您还可以尝试 {times_try} 次(账号将被临时 锁"
|
"该({mfa_type}) MFA 类型不支持, 您还可以尝试 {times_try} 次(账号将被临时 锁"
|
||||||
"定 {block_time} 分钟)"
|
"定 {block_time} 分钟)"
|
||||||
|
|
||||||
#: authentication/errors.py:79
|
#: authentication/errors.py:79
|
||||||
|
@ -1776,11 +1776,12 @@ msgstr "CAS"
|
||||||
msgid "FeiShu"
|
msgid "FeiShu"
|
||||||
msgstr "飞书"
|
msgstr "飞书"
|
||||||
|
|
||||||
#: authentication/templates/authentication/login_otp.html:25
|
#: authentication/templates/authentication/login_otp.html:24
|
||||||
msgid "Please enter the verification code"
|
msgid "Please enter the verification code"
|
||||||
msgstr "请输入验证码"
|
msgstr "请输入验证码"
|
||||||
|
|
||||||
#: authentication/templates/authentication/login_otp.html:28
|
#: authentication/templates/authentication/login_otp.html:25
|
||||||
|
#: authentication/templates/authentication/login_otp.html:75
|
||||||
msgid "Send verification code"
|
msgid "Send verification code"
|
||||||
msgstr "发送验证码"
|
msgstr "发送验证码"
|
||||||
|
|
||||||
|
@ -1792,10 +1793,19 @@ msgstr "发送验证码"
|
||||||
msgid "Next"
|
msgid "Next"
|
||||||
msgstr "下一步"
|
msgstr "下一步"
|
||||||
|
|
||||||
#: authentication/templates/authentication/login_otp.html:32
|
#: authentication/templates/authentication/login_otp.html:31
|
||||||
msgid "Can't provide security? Please contact the administrator!"
|
msgid "Can't provide security? Please contact the administrator!"
|
||||||
msgstr "如果不能提供多因子认证验证码,请联系管理员!"
|
msgstr "如果不能提供多因子认证验证码,请联系管理员!"
|
||||||
|
|
||||||
|
#: authentication/templates/authentication/login_otp.html:68
|
||||||
|
#: authentication/templates/authentication/login_otp.html:73
|
||||||
|
msgid "Wait: "
|
||||||
|
msgstr "等待:"
|
||||||
|
|
||||||
|
#: authentication/templates/authentication/login_otp.html:81
|
||||||
|
msgid "The verification code has been sent"
|
||||||
|
msgstr "验证码已发送"
|
||||||
|
|
||||||
#: authentication/templates/authentication/login_wait_confirm.html:41
|
#: authentication/templates/authentication/login_wait_confirm.html:41
|
||||||
msgid "Refresh"
|
msgid "Refresh"
|
||||||
msgstr "刷新"
|
msgstr "刷新"
|
||||||
|
@ -2082,7 +2092,7 @@ msgstr "腾讯云"
|
||||||
|
|
||||||
#: common/message/backends/sms/__init__.py:74
|
#: common/message/backends/sms/__init__.py:74
|
||||||
msgid "SMS provider not support: {}"
|
msgid "SMS provider not support: {}"
|
||||||
msgstr "不支持 SMS 服务商: {}"
|
msgstr "短信服务商不支持:{}"
|
||||||
|
|
||||||
#: common/message/backends/sms/alibaba.py:56
|
#: common/message/backends/sms/alibaba.py:56
|
||||||
msgid "Signature does not match"
|
msgid "Signature does not match"
|
||||||
|
@ -2771,7 +2781,7 @@ msgstr "启用 SMS"
|
||||||
|
|
||||||
#: settings/serializers/auth/sms.py:11
|
#: settings/serializers/auth/sms.py:11
|
||||||
msgid "SMS provider"
|
msgid "SMS provider"
|
||||||
msgstr "SMS 服务商"
|
msgstr "短信服务商"
|
||||||
|
|
||||||
#: settings/serializers/auth/sms.py:15 settings/serializers/email.py:69
|
#: settings/serializers/auth/sms.py:15 settings/serializers/email.py:69
|
||||||
msgid "Signature"
|
msgid "Signature"
|
||||||
|
@ -2779,7 +2789,7 @@ msgstr "署名"
|
||||||
|
|
||||||
#: settings/serializers/auth/sms.py:16
|
#: settings/serializers/auth/sms.py:16
|
||||||
msgid "Template"
|
msgid "Template"
|
||||||
msgstr "模版"
|
msgstr "模板"
|
||||||
|
|
||||||
#: settings/serializers/auth/sms.py:20
|
#: settings/serializers/auth/sms.py:20
|
||||||
msgid "Test phone"
|
msgid "Test phone"
|
||||||
|
@ -6161,6 +6171,9 @@ msgstr "旗舰版"
|
||||||
msgid "Community edition"
|
msgid "Community edition"
|
||||||
msgstr "社区版"
|
msgstr "社区版"
|
||||||
|
|
||||||
|
#~ msgid "Obtaining verification code"
|
||||||
|
#~ msgstr "发送验证码"
|
||||||
|
|
||||||
#~ msgid "Alibaba"
|
#~ msgid "Alibaba"
|
||||||
#~ msgstr "阿里云"
|
#~ msgstr "阿里云"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue