61 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			HTML
		
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			HTML
		
	
	
| {% block body %}
 | |
|     <meta charset="utf-8" name="viewport"
 | |
|           content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=3.0, user-scalable=yes"/>
 | |
|     <link rel="stylesheet" href="static/css/login_service.css">
 | |
|     <script src="static/js/jquery.js"></script>
 | |
|     <script src="static/js/password.js"></script>
 | |
|     <script>
 | |
|         function reset() {
 | |
|             let old_password = $("#old-password").val();
 | |
|             let new_password = $("#new-password").val();
 | |
|             let re_new_password = $("#re-new-password").val();
 | |
|             if (old_password === "" || new_password === "" || re_new_password === ""){
 | |
|                 alert('输入不能为空!');
 | |
|                 return false;
 | |
|             }
 | |
|             if (old_password.includes(' ') || new_password.includes(' ')) {
 | |
|                 alert('输入不能包含空格!');
 | |
|                 return false;
 | |
|             }
 | |
|             if (new_password !== re_new_password) {
 | |
|                 alert('新密码不匹配,请重新输入');
 | |
|                 return false;
 | |
|             }
 | |
|             if (new_password.length < 4) {
 | |
|                 alert('密码过于简单。(密码长度至少4位)');
 | |
|                 return false;
 | |
|             }
 | |
|             if (!containsDigitsLettersSpecialCharacters(new_password)) {
 | |
| 		alert('密码过于简单。(密码要包括数字,字母,特殊符号)');
 | |
| 		return false;
 | |
|             }
 | |
|             $.post("/reset", {'old-password': old_password, 'new-password': new_password},
 | |
|                    function (response) {
 | |
| 		       console.log(response);
 | |
|                     if ('success' in response) {
 | |
|                         alert('密码修改成功。');
 | |
|                     } else if ('error' in response) {
 | |
|                         alert(`密码修改失败 ${response.error}`);
 | |
|                     }
 | |
|                     window.location.href = `/${response.username}/userpage`;
 | |
|                 }
 | |
|             )
 | |
|             return false;
 | |
|         }
 | |
|     </script>
 | |
| 
 | |
|     <div class="container">
 | |
| 
 | |
|         <section class="reset-heading">
 | |
|             <h1>Reset Password</h1>
 | |
|         </section>
 | |
| 
 | |
|         <input type="password" placeholder="原密码" class="old-password" name="old-password" id="old-password"/>
 | |
|         <input type="password" placeholder="新密码" class="new-password" name="new-password" id="new-password"/>
 | |
|         <input type="password" placeholder="确认新密码" class="re-new-password" name="re-new-password" id="re-new-password"/>
 | |
|         <button id="submit" class="btn" onclick="reset()">提交</button>
 | |
|         <button class="btn" onclick="window.location.href='/{{ username }}/userpage'">放弃修改</button>
 | |
| 
 | |
|     </div>
 | |
| {% endblock %}
 |