| 
									
										
										
										
											2022-12-03 20:52:01 +08:00
										 |  |  | {% 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"> | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |     <script src="static/js/jquery.js"></script> | 
					
						
							| 
									
										
										
										
											2024-09-06 08:54:11 +08:00
										 |  |  |     <script src="static/js/password.js"></script> | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |     <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; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-04-06 00:18:44 +08:00
										 |  |  |             if (old_password.includes(' ') || new_password.includes(' ')) { | 
					
						
							|  |  |  |                 alert('输入不能包含空格!'); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |             if (new_password !== re_new_password) { | 
					
						
							|  |  |  |                 alert('新密码不匹配,请重新输入'); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             if (new_password.length < 4) { | 
					
						
							|  |  |  |                 alert('密码过于简单。(密码长度至少4位)'); | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-09-06 08:54:11 +08:00
										 |  |  |             if (!containsDigitsLettersSpecialCharacters(new_password)) { | 
					
						
							|  |  |  | 		alert('密码过于简单。(密码要包括数字,字母,特殊符号)'); | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |             $.post("/reset", {'old-password': old_password, 'new-password': new_password}, | 
					
						
							| 
									
										
										
										
											2024-09-06 08:54:11 +08:00
										 |  |  |                    function (response) { | 
					
						
							|  |  |  | 		       console.log(response); | 
					
						
							|  |  |  |                     if ('success' in response) { | 
					
						
							|  |  |  |                         alert('密码修改成功。'); | 
					
						
							|  |  |  |                     } else if ('error' in response) { | 
					
						
							|  |  |  |                         alert(`密码修改失败 ${response.error}`); | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |                     } | 
					
						
							| 
									
										
										
										
											2024-09-06 08:54:11 +08:00
										 |  |  |                     window.location.href = `/${response.username}/userpage`; | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |                 } | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     </script> | 
					
						
							| 
									
										
										
										
											2022-12-03 20:52:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     <div class="container"> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         <section class="reset-heading"> | 
					
						
							|  |  |  |             <h1>Reset Password</h1> | 
					
						
							|  |  |  |         </section> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |         <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> | 
					
						
							| 
									
										
										
										
											2023-04-20 20:30:14 +08:00
										 |  |  |         <button class="btn" onclick="window.location.href='/{{ username }}/userpage'">放弃修改</button> | 
					
						
							| 
									
										
										
										
											2022-12-03 20:52:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     </div> | 
					
						
							| 
									
										
										
										
											2024-09-06 08:54:11 +08:00
										 |  |  | {% endblock %} |