Skip to content

Commit

Permalink
Merge pull request #42 from x-team/issue/25
Browse files Browse the repository at this point in the history
Fix incorrect logout messages on failed logins, #25
  • Loading branch information
frankiejarrett committed Dec 8, 2013
2 parents 4951055 + 26a1d26 commit 77b0d3e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions connectors/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class WP_Stream_Connector_Users extends WP_Stream_Connector {
'clear_auth_cookie',
'delete_user',
'deleted_user',
'wp_login_failed',
);

/**
Expand All @@ -54,6 +55,7 @@ public static function get_action_labels() {
'forgot-password' => __( 'Forgot Password', 'stream' ),
'login' => __( 'Login', 'stream' ),
'logout' => __( 'Logout', 'stream' ),
'failed_login' => __( 'Failed Login', 'stream' ),
);
}

Expand Down Expand Up @@ -230,6 +232,10 @@ public static function callback_wp_login( $user_login, $user ) {
*/
public static function callback_clear_auth_cookie() {
$user = wp_get_current_user();
// For some reason, ignito mode calls clear_auth_cookie on failed login attempts
if ( empty( $user ) ) {
return;
}
self::log(
__( '%s logged out', 'stream' ),
array(
Expand Down Expand Up @@ -293,4 +299,21 @@ public static function callback_deleted_user( $user_id ) {
);
}

/**
* Track failed login attempts
* @param arary $errors
* @param string $redirect_to
* @return array
*/
public static function callback_wp_login_failed( $username ) {
$user = get_user_by( 'login', $username );
self::log(
__( 'Invalid login attempt for %s', 'stream' ),
compact( 'username' ),
$user ? $user->ID : 0,
array( 'users' => 'failed_login' ),
$user ? $user->ID : 0
);
}

}

0 comments on commit 77b0d3e

Please sign in to comment.