@@ -47,6 +47,10 @@ def login():
4747 username = request .form ['username' ]
4848 password = request .form ['password' ]
4949
50+ if username and password :
51+ if len (username ) > 64 or len (password ) > 64 :
52+ return render_template ('login.html' )
53+
5054 auth_res = authenticate_basic (username , password )
5155 if auth_res and auth_res .get_success ():
5256 # Reset failed login attempts for this client IP
@@ -64,18 +68,21 @@ def login():
6468 # Increment failed login attempts for this client IP
6569 failed_login_attempts [client_ip ] += 1
6670
71+ flash ("Invalid credentials" , "error" )
72+
6773 # increase the timeout based on the number of failed attempts
6874 if failed_login_attempts [client_ip ] >= 10 :
6975 Logger .log_info (f"Locking out client { client_ip } for 30 minutes due to too many failed login attempts." )
7076 timeouts [client_ip ] = datetime .now () + timedelta (minutes = 30 )
77+ return render_template ('lockout.html' )
7178 elif failed_login_attempts [client_ip ] >= 5 :
7279 Logger .log_info (f"Locking out client { client_ip } for 10 minutes due to too many failed login attempts." )
7380 timeouts [client_ip ] = datetime .now () + timedelta (minutes = 10 )
81+ return render_template ('lockout.html' )
7482 elif failed_login_attempts [client_ip ] >= 3 :
7583 Logger .log_info (f"Locking out client { client_ip } for 5 minutes due to too many failed login attempts." )
7684 timeouts [client_ip ] = datetime .now () + timedelta (minutes = 5 )
77-
78- flash ("Invalid credentials" , "error" )
85+ return render_template ('lockout.html' )
7986
8087 return render_template ('login.html' )
8188
0 commit comments