Browse Source

fix: 忘记密码短信验证码过期

pull/12981/head
wangruidong 8 months ago committed by Bryan
parent
commit
1e0ea3905e
  1. 3
      apps/users/forms/profile.py
  2. 2
      apps/users/templates/users/forgot_password.html
  3. 2
      apps/users/views/profile/reset.py

3
apps/users/forms/profile.py

@ -7,7 +7,6 @@ from common.utils import validate_ssh_public_key
from authentication.forms import EncryptedField, CaptchaMixin
from ..models import User
__all__ = [
'UserProfileForm', 'UserMFAForm', 'UserFirstLoginFinishForm',
'UserPasswordForm', 'UserPublicKeyForm', 'FileForm',
@ -45,7 +44,6 @@ UserProfileForm.verbose_name = _("Profile")
class UserMFAForm(forms.ModelForm):
mfa_description = _(
'When enabled, '
'you will enter the MFA binding process the next time you log in. '
@ -100,6 +98,7 @@ class UserTokenResetPasswordForm(forms.Form):
class UserForgotPasswordForm(forms.Form):
email = forms.CharField(label=_("Email"), required=False)
country_code = forms.CharField(required=False)
sms = forms.CharField(
label=_('SMS'), required=False,
help_text=_('The phone number must contain an area code, for example, +86')

2
apps/users/templates/users/forgot_password.html

@ -78,6 +78,7 @@
<span class="country-code-value">+86</span>
</button>
<ul class="dropdown-menu scrollable-menu">
<input type="hidden" name="country_code" id="country_code" value="+86">
{% for country in countries %}
<li>
<a href="#" class="dropdown-item d-flex justify-content-between">
@ -121,6 +122,7 @@
const inputGroupAddon = inputGroup.find('.country-code-value');
const selectedCountry = $(evt.target).closest('li');
const selectedCountryCode = selectedCountry.find('.country-code').html();
$('#country_code').val(selectedCountryCode)
inputGroupAddon.html(selectedCountryCode)
});

2
apps/users/views/profile/reset.py

@ -146,10 +146,12 @@ class UserForgotPasswordView(FormView):
form_type = form.cleaned_data['form_type']
target = form.cleaned_data[form_type]
code = form.cleaned_data['code']
country_code = form.cleaned_data.get('country_code', '')
query_key = form_type
if form_type == 'sms':
query_key = 'phone'
target = '{}{}'.format(country_code, target)
try:
self.safe_verify_code(token, target, form_type, code)

Loading…
Cancel
Save