login_security error
-
In my PHP error log, I was seeing a whole bunch of errors related to login_security.php. I deleted the error so I can’t remember exactly the text, but it said something like “function expects an object.”
I looked into the file and found that at the referenced lines (417 and 434), it’s trying to use the created $user object retrieved from get_user_by(). In most situations this is fine. But it turns out (which I tested by having it print the username prior to the error) that people were trying to hack my site by logging in as two specific usernames:
admin (which I had previously deleted from the wordpress DB but still existed in the BPS login database – I cleared that up by deleting admin from the BPS login table)
park-boulevard (which is the name of our domain, and would be part of all email addresses that employees would use to log in)I’m not sure why park-boulevard was able to pass through to this point, but the issue appeared that it was verified up to this point but couldn’t actually resolve to a user ID in get_user_by() leaving the $user object empty. I solved this as a temporary measure by encapsulating all of the code following the get_user_by() function in an if($user) statement.
I’m not sure if there’s a better way to prevent that username from getting through up to that point, but I’m writing just to at least make sure that $user check gets added so the errors don’t come back in the next update.
*******************************************************************************************************************
// Log Only Account Lockouts for valid Users
// X failed attempts in any X amount of time = account is locked period – Duration/threshold is totally unnecessary
*******************************************************************************************************************
*/
if ( $BPSoptions[‘bps_login_security_OnOff’] == ‘On’ && $BPSoptions[‘bps_login_security_logging’] == ‘logLockouts’) {$user = get_user_by( ‘login’, $username );
// .53.8: Login by email address
if ( ! $user && strpos( $username, ‘@’ ) ) {
$user = get_user_by( ’email’, $username );
}if ($user) { //added this (and then of course an end brace to close it)
$LoginSecurityRows = $wpdb->get_results( $wpdb->prepare(“SELECT * FROM $bpspro_login_table WHERE user_id = %d”, $user->ID) ); //this line threw the error first
The topic ‘login_security error’ is closed to new replies.