Skip to content

Commit

Permalink
Patch in a hook to two-factor. See WordPress/two-factor#620
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Oct 8, 2024
1 parent f9b1c47 commit 10f9e9d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion revalidation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,25 @@ function clear_cookie() {
}

setcookie( COOKIE_NAME, '', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), false );
}
}

/**
* Temporarily abuse a filter to patch in an action.
*
* This filter is run just before the login form is output.
*
* @see https://github.com/WordPress/two-factor/pull/620
*/
add_filter( 'login_title', static function( $title ) {
if (
is_user_logged_in() &&
isset( $_REQUEST['action'] ) &&
'revalidate_2fa' == $_REQUEST['action'] &&
! get_revalidation_status()['needs_revalidate'] &&
! did_action( 'two_factor_user_revalidated' )
) {
do_action( 'two_factor_user_revalidated', wp_get_current_user(), false );
}

return $title;
} );

0 comments on commit 10f9e9d

Please sign in to comment.