Skip to content

Commit

Permalink
perf: Optimize the password reset page experience for new users (the …
Browse files Browse the repository at this point in the history
…password field will be lengthened)
  • Loading branch information
feng626 authored and BaiJiangJie committed Jul 12, 2024
1 parent c0d2efa commit e9f4615
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions apps/users/templates/users/reset_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ <h4 style="margin-top: 10px;">{% trans 'Password strength' %}</h4><div id="id_pr
// 密码强度校验
var el = $('#id_password_rules'),
idPassword = $('#id_new_password'),
idConfirmPassword = $('#id_confirm_password'),
idPopover = $('#popover777'),
container = $('#container'),
progress = $('#id_progress'),
Expand Down Expand Up @@ -82,15 +83,21 @@ <h4 style="margin-top: 10px;">{% trans 'Password strength' %}</h4><div id="id_pr
$("form").submit(function(event){
event.preventDefault()
// Let's find the input to check
var ids = ['id_new_password', 'id_confirm_password']
for (id of ids) {
var passwordRef = $('#' + id)
var value = passwordRef.val()
if (value) {
value = encryptPassword(value)
passwordRef.val(value)
}
}
var encryptedPassword = encryptPassword(idPassword.val());
var encryptedConfirmPassword = encryptPassword(idConfirmPassword.val());

var hiddenPasswordField = $('<input>', {
type: 'hidden',
name: 'new_password',
value: encryptedPassword
});
var hiddenConfirmPasswordField = $('<input>', {
type: 'hidden',
name: 'confirm_password',
value: encryptedConfirmPassword
});

$(this).append(hiddenPasswordField, hiddenConfirmPasswordField);
this.submit();
});
})
Expand Down

0 comments on commit e9f4615

Please sign in to comment.