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)"
|
||||
)
|
||||
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 "
|
||||
"(The account will be temporarily locked for {block_time} minutes)"
|
||||
)
|
||||
|
|
|
@ -52,10 +52,13 @@ class VerifyCodeUtil:
|
|||
ttl = self.ttl()
|
||||
if ttl > 0:
|
||||
raise CodeSendTooFrequently(ttl)
|
||||
|
||||
self.generate()
|
||||
self.save()
|
||||
self.send()
|
||||
try:
|
||||
self.generate()
|
||||
self.save()
|
||||
self.send()
|
||||
except JMSException:
|
||||
self.clear()
|
||||
raise
|
||||
|
||||
def generate(self):
|
||||
code = ''.join(random.sample('0123456789', 4))
|
||||
|
|
|
@ -19,19 +19,25 @@
|
|||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<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>
|
||||
<div class="form-group" style="display: flex">
|
||||
|
||||
<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>
|
||||
<small>{% trans "Can't provide security? Please contact the administrator!" %}</small>
|
||||
</div>
|
||||
</form>
|
||||
<style type="text/css">
|
||||
.disabledBtn {
|
||||
background: #e6e4e4!important;
|
||||
border-color: #d8d5d5!important;
|
||||
color: #949191!important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
var methodSelect = document.getElementById('verify-method-select');
|
||||
|
@ -44,19 +50,35 @@
|
|||
|
||||
if (type == "sms") {
|
||||
currentBtn.style.display = "block";
|
||||
currentBtn.disabled = false;
|
||||
}
|
||||
else {
|
||||
currentBtn.style.display = "none";
|
||||
currentBtn.disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
function sendSMSVerifyCode(){
|
||||
var currentBtn = document.getElementById('send-sms-verify-code');
|
||||
var time = 60
|
||||
var url = "{% url 'api-auth:sms-verify-code-send' %}";
|
||||
requestApi({
|
||||
url: url,
|
||||
method: "POST",
|
||||
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) {
|
||||
alert(data.detail)
|
||||
|
|
|
@ -32,7 +32,7 @@ class UserLoginOtpView(mixins.AuthMixin, FormView):
|
|||
except Exception as e:
|
||||
logger.error(e)
|
||||
import traceback
|
||||
traceback.print_exception()
|
||||
traceback.print_exception(e)
|
||||
return redirect_to_guard_view()
|
||||
|
||||
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 "
|
||||
"be temporarily locked for {block_time} minutes)"
|
||||
msgstr ""
|
||||
"短信验证码不正确,或者服务器端时间不对。 您还可以尝试 {times_try} 次(账号将"
|
||||
"被临时 锁定 {block_time} 分钟)"
|
||||
"短信验证码不正确。 您还可以尝试 {times_try} 次(账号将被临时 锁定 "
|
||||
"{block_time} 分钟)"
|
||||
|
||||
#: authentication/errors.py:74
|
||||
#, python-brace-format
|
||||
msgid ""
|
||||
"The MFA type({mfa_type}) is not supportedYou can also try {times_try} times "
|
||||
"(The account will be temporarily locked for {block_time} minutes)"
|
||||
"The MFA type({mfa_type}) is not supported, You can also try {times_try} "
|
||||
"times (The account will be temporarily locked for {block_time} minutes)"
|
||||
msgstr ""
|
||||
"该 ({mfa_type}) MFA 类型不支持。 您还可以尝试 {times_try} 次(账号将被临时 锁"
|
||||
"该({mfa_type}) MFA 类型不支持, 您还可以尝试 {times_try} 次(账号将被临时 锁"
|
||||
"定 {block_time} 分钟)"
|
||||
|
||||
#: authentication/errors.py:79
|
||||
|
@ -1776,11 +1776,12 @@ msgstr "CAS"
|
|||
msgid "FeiShu"
|
||||
msgstr "飞书"
|
||||
|
||||
#: authentication/templates/authentication/login_otp.html:25
|
||||
#: authentication/templates/authentication/login_otp.html:24
|
||||
msgid "Please enter the verification code"
|
||||
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"
|
||||
msgstr "发送验证码"
|
||||
|
||||
|
@ -1792,10 +1793,19 @@ msgstr "发送验证码"
|
|||
msgid "Next"
|
||||
msgstr "下一步"
|
||||
|
||||
#: authentication/templates/authentication/login_otp.html:32
|
||||
#: authentication/templates/authentication/login_otp.html:31
|
||||
msgid "Can't provide security? Please contact the administrator!"
|
||||
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
|
||||
msgid "Refresh"
|
||||
msgstr "刷新"
|
||||
|
@ -2082,7 +2092,7 @@ msgstr "腾讯云"
|
|||
|
||||
#: common/message/backends/sms/__init__.py:74
|
||||
msgid "SMS provider not support: {}"
|
||||
msgstr "不支持 SMS 服务商: {}"
|
||||
msgstr "短信服务商不支持:{}"
|
||||
|
||||
#: common/message/backends/sms/alibaba.py:56
|
||||
msgid "Signature does not match"
|
||||
|
@ -2771,7 +2781,7 @@ msgstr "启用 SMS"
|
|||
|
||||
#: settings/serializers/auth/sms.py:11
|
||||
msgid "SMS provider"
|
||||
msgstr "SMS 服务商"
|
||||
msgstr "短信服务商"
|
||||
|
||||
#: settings/serializers/auth/sms.py:15 settings/serializers/email.py:69
|
||||
msgid "Signature"
|
||||
|
@ -2779,7 +2789,7 @@ msgstr "署名"
|
|||
|
||||
#: settings/serializers/auth/sms.py:16
|
||||
msgid "Template"
|
||||
msgstr "模版"
|
||||
msgstr "模板"
|
||||
|
||||
#: settings/serializers/auth/sms.py:20
|
||||
msgid "Test phone"
|
||||
|
@ -6161,6 +6171,9 @@ msgstr "旗舰版"
|
|||
msgid "Community edition"
|
||||
msgstr "社区版"
|
||||
|
||||
#~ msgid "Obtaining verification code"
|
||||
#~ msgstr "发送验证码"
|
||||
|
||||
#~ msgid "Alibaba"
|
||||
#~ msgstr "阿里云"
|
||||
|
||||
|
|
Loading…
Reference in New Issue