From e9f4615caa9dee3059ef6589b1ce2823d608fad1 Mon Sep 17 00:00:00 2001
From: feng <1304903146@qq.com>
Date: Thu, 11 Jul 2024 18:00:09 +0800
Subject: [PATCH] perf: Optimize the password reset page experience for new
users (the password field will be lengthened)
---
.../users/templates/users/reset_password.html | 25 ++++++++++++-------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/apps/users/templates/users/reset_password.html b/apps/users/templates/users/reset_password.html
index f75e3dae5..cd85c4a03 100644
--- a/apps/users/templates/users/reset_password.html
+++ b/apps/users/templates/users/reset_password.html
@@ -41,6 +41,7 @@ $(document).ready(function () {
// 密码强度校验
var el = $('#id_password_rules'),
idPassword = $('#id_new_password'),
+ idConfirmPassword = $('#id_confirm_password'),
idPopover = $('#popover777'),
container = $('#container'),
progress = $('#id_progress'),
@@ -82,15 +83,21 @@ $(document).ready(function () {
$("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 = $('', {
+ type: 'hidden',
+ name: 'new_password',
+ value: encryptedPassword
+ });
+ var hiddenConfirmPasswordField = $('', {
+ type: 'hidden',
+ name: 'confirm_password',
+ value: encryptedConfirmPassword
+ });
+
+ $(this).append(hiddenPasswordField, hiddenConfirmPasswordField);
this.submit();
});
})