Skip to content

Commit

Permalink
Move the description to the main docblock
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Jan 10, 2025
1 parent 7cb84f5 commit cf0852b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,9 @@ public static function destroy_current_session_for_user( $user ) {
}

/**
* Prevent login through XML-RPC and REST API for users with at least one
* two-factor method enabled.
* Trigget the two-factor workflow only for valid login attempts
* with username present. Prevent authentication during API requests
* unless explicitly enabled for the user (disabled by default).
*
* @param WP_User|WP_Error $user Valid WP_User only if the previous filters
* have verified and confirmed the
Expand All @@ -689,17 +690,16 @@ public static function destroy_current_session_for_user( $user ) {
* @return WP_User|WP_Error
*/
public static function filter_authenticate( $user, $username ) {
// Trigger the two-factor workflow only for login attempts and non-existent user sessions.
if ( strlen( $username ) && $user instanceof WP_User ) {
if ( strlen( $username ) && $user instanceof WP_User && self::is_user_using_two_factor( $user->ID ) ) {
// Disable authentication requests for API requests for users with two-factor enabled.
if ( self::is_api_request() && self::is_user_using_two_factor( $user->ID ) && ! self::is_user_api_login_enabled( $user->ID ) ) {
if ( self::is_api_request() && ! self::is_user_api_login_enabled( $user->ID ) ) {
return new WP_Error(
'invalid_application_credentials',
__( 'Error: API login for user disabled.', 'two-factor' )
);
}

// Trigger the second-factor flow only for login attempts.
// Trigger the two-factor flow only for login attempts.
add_action( 'wp_login', array( __CLASS__, 'wp_login' ), PHP_INT_MAX, 2 );
}

Expand Down

0 comments on commit cf0852b

Please sign in to comment.