| 
									
										
										
										
											2022-01-26 21:10:09 +08:00
										 |  |  | {% block body %} | 
					
						
							|  |  |  | {% if session['logged_in'] %} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 16:48:45 +08:00
										 |  |  | 你已登录 <a href="/{{ session['username'] }}/userpage">{{ session['username'] }}</a>。 登出点击<a href="/logout">这里</a>。 | 
					
						
							| 
									
										
										
										
											2022-01-26 21:10:09 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | {% else %} | 
					
						
							|  |  |  | <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" /> | 
					
						
							| 
									
										
										
										
											2022-12-03 20:52:01 +08:00
										 |  |  | <link rel="stylesheet" href="static/css/login_service.css"> | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  | <script src="static/js/jquery.js"></script> | 
					
						
							|  |  |  | <script> | 
					
						
							| 
									
										
										
										
											2024-07-04 11:16:32 +08:00
										 |  |  | let blackList = []; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <!--function getBlack() {--> | 
					
						
							|  |  |  | <!--    const fs = require('fs');--> | 
					
						
							|  |  |  | <!--    global.blackFile = fs.readFileSync('black', 'utf8');--> | 
					
						
							|  |  |  | <!--    const blackListTemp = blackFile.split('\n');--> | 
					
						
							|  |  |  | <!--    global.blackList = blackListTemp.map(line => line.trim()).filter(line => line !== '');--> | 
					
						
							|  |  |  | <!--}--> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function putUserIntoBlack(usernameTemp) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     blackList.push(usernameTemp); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function ifUsernameInBlack(usernameTemp) { | 
					
						
							|  |  |  |     return blackList.includes(usernameTemp); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     count=0 | 
					
						
							|  |  |  |     function login() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |         let username = $("#username").val(); | 
					
						
							|  |  |  |         let password = $("#password").val(); | 
					
						
							|  |  |  |         if (username === "" || password === ""){ | 
					
						
							|  |  |  |             alert('输入不能为空!'); | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-04-15 06:12:41 +08:00
										 |  |  |         if (password.includes(' ')) { | 
					
						
							|  |  |  |             alert('输入不能包含空格!'); | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2024-07-04 11:16:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           $.post | 
					
						
							|  |  |  |           ( | 
					
						
							|  |  |  |               "/login", {'username': username, 'password': password}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |               function (response) | 
					
						
							|  |  |  |               { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 if(response.status === '5') | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                   alert('已被加入黑名单,请联系管理员!'); | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else{ | 
					
						
							|  |  |  |                 if(!ifUsernameInBlack(username)) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                   if (response.status === '0') | 
					
						
							|  |  |  |                   { | 
					
						
							|  |  |  |                       if(count<5) | 
					
						
							|  |  |  |                       { | 
					
						
							|  |  |  |                           alert('无法通过验证。'); | 
					
						
							|  |  |  |                           <!--window.location.href = "/login";--> | 
					
						
							|  |  |  |                           count++; | 
					
						
							|  |  |  |                       } | 
					
						
							|  |  |  |                        else | 
					
						
							|  |  |  |                       { | 
					
						
							|  |  |  |                           <!--输入错误密码次数超过5次--> | 
					
						
							|  |  |  |                           alert('密码输入错误超过五次,已被加入黑名单!'); | 
					
						
							|  |  |  |                           putUserIntoBlack(username); | 
					
						
							|  |  |  |                           console.log(ifUsernameInBlack(username)); | 
					
						
							|  |  |  |                           response.status=5; | 
					
						
							|  |  |  |                            $("#password").val('黑名单'); | 
					
						
							|  |  |  |                       } | 
					
						
							|  |  |  |                   } | 
					
						
							|  |  |  |                   else if (response.status === '1') | 
					
						
							|  |  |  |                   { | 
					
						
							|  |  |  |                         window.location.href = "/"+username+"/userpage"; | 
					
						
							|  |  |  |                   } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 else if(ifUsernameInBlack(username)) | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     alert('已被加入黑名单!'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-07-04 11:16:32 +08:00
										 |  |  |                 } | 
					
						
							|  |  |  |               } | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | </script> | 
					
						
							| 
									
										
										
										
											2022-07-20 17:06:11 +08:00
										 |  |  | <div class="container"> | 
					
						
							| 
									
										
										
										
											2022-07-20 17:08:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-20 17:06:11 +08:00
										 |  |  |   <section class="signin-heading"> | 
					
						
							| 
									
										
										
										
											2023-08-11 19:32:34 +08:00
										 |  |  |     <h1>Sign in</h1> | 
					
						
							| 
									
										
										
										
											2022-07-20 17:06:11 +08:00
										 |  |  |   </section> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-08 16:33:13 +08:00
										 |  |  |   <input type="text" placeholder="用户名" class="username" id="username"> | 
					
						
							|  |  |  |   <input type="password" placeholder="密码" class="password"  id="password"> | 
					
						
							|  |  |  |   <button type="button" class="btn" onclick="login()">登录</button> | 
					
						
							|  |  |  |   <a class="signup" href="/signup">注册</a> | 
					
						
							| 
									
										
										
										
											2022-07-20 17:07:09 +08:00
										 |  |  | </div> | 
					
						
							| 
									
										
										
										
											2022-07-20 17:08:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | {% endif %} | 
					
						
							|  |  |  | {% endblock %} | 
					
						
							| 
									
										
										
										
											2022-01-26 21:10:09 +08:00
										 |  |  | 
 |