@@ -157,6 +157,7 @@ def login(self):
157
157
username = req .get (self .USERNAME )
158
158
password = req .get (self .PASSWORD )
159
159
if username :
160
+ self .logger .debug ("Attempting to login via POST params as %s" % username )
160
161
user = self .find_user (db_session , name = username )
161
162
login_success , login_fail_reason = self .__user_is_authorized (user , password )
162
163
if login_success :
@@ -173,6 +174,7 @@ def login(self):
173
174
form .terms_url = self .terms_url
174
175
form .favicon = self .favicon
175
176
if form .validate_on_submit ():
177
+ self .logger .debug ("Attempting to login via form as %s" % form .username .data )
176
178
user = self .find_user (db_session , name = form .username .data )
177
179
178
180
# force password change on first sign in of default admin user
@@ -705,6 +707,7 @@ def __user_is_authorized(self, user, password):
705
707
706
708
if user is None or user .password_hash is None :
707
709
# invalid username or no password set
710
+ self .logger .debug ("Invalid username or no password set for user" )
708
711
return False , i18n .t ('auth.auth_failed' )
709
712
elif user .check_password (password ):
710
713
# valid credentials
@@ -715,9 +718,11 @@ def __user_is_authorized(self, user, password):
715
718
user .last_sign_in_at = datetime .datetime .now (datetime .UTC )
716
719
user .failed_sign_in_count = 0
717
720
721
+ self .logger .debug ("User is authorized" )
718
722
return True , None
719
723
else :
720
724
# block sign in due to too many login attempts
725
+ self .logger .debug ("User is authorized but account is locked" )
721
726
return False , i18n .t ('auth.account_locked' )
722
727
else :
723
728
# invalid password
@@ -733,8 +738,10 @@ def __user_is_authorized(self, user, password):
733
738
user .failed_sign_in_count += 1
734
739
735
740
if user .failed_sign_in_count < self .max_login_attempts :
741
+ self .logger .debug ("User is not authorized" )
736
742
return False , i18n .t ('auth.auth_failed' )
737
743
else :
744
+ self .logger .debug ("User is not authorized, account is locked due to too many attempts" )
738
745
return False , i18n .t ('auth.account_locked' )
739
746
740
747
def user_totp_is_valid (self , user , token ):
0 commit comments