Making WordPress.org


Ignore:
Timestamp:
10/09/2019 07:07:07 AM (7 years ago)
Author:
dd32
Message:

Login: Require a valid reCaptcha v3 score during registration, add reCaptcha to the account confirmation screen as well.

See #4739.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/functions-registration.php

    r9147 r9167  
    11<?php
    22
    3 function wporg_login_check_recapcha_status() {
     3function wporg_login_check_recapcha_status( $check_v3_action = false ) {
     4
     5    // reCaptcha V3 Checks
     6    if ( $check_v3_action ) {
     7        if ( empty( $_POST['_reCaptcha_v3_token'] ) ) {
     8            return false;
     9        }
     10        $result = wporg_login_recaptcha_api(
     11            $_POST['_reCaptcha_v3_token'],
     12            RECAPTCHA_V3_PRIVKEY
     13        );
     14
     15        if (
     16            ! $result ||
     17            ! $result['success'] ||
     18            $check_v3_action !== $result['action']
     19        ) {
     20            return false;
     21        }
     22
     23        // Block super-low scores.
     24        if ( (float)$result['score'] < (float) get_option( 'recaptcha_v3_threshold', 0.2 ) ) {
     25            return false;
     26        }
     27    }
     28
     29    // reCaptcha V2 Checks
    430    if ( empty( $_POST['g-recaptcha-response'] ) ) {
    531        return false;
     
    1440        return false;
    1541    }
     42
    1643    return (bool) $result['success'];
    1744}
Note: See TracChangeset for help on using the changeset viewer.