Make WordPress Core


Ignore:
Timestamp:
04/27/2018 10:12:01 AM (8 years ago)
Author:
azaozz
Message:

Privacy: update the method to confirm user requests by email. Use a single CPT to store the requests and to allow logging/audit trail.

Props mikejolley.
See #43443.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r42964 r43008  
    428428
    429429// validate action so as to default to the login screen
    430 if ( ! in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login', 'verifyaccount' ), true ) && false === has_filter( 'login_form_' . $action ) ) {
     430if ( ! in_array( $action, array( 'postpass', 'logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login', 'confirmaction' ), true ) && false === has_filter( 'login_form_' . $action ) ) {
    431431        $action = 'login';
    432432}
     
    859859                break;
    860860
    861         case 'verifyaccount' :
    862                 if ( isset( $_GET['confirm_action'], $_GET['confirm_key'], $_GET['uid'] ) ) {
    863                         $key         = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
    864                         $uid         = sanitize_text_field( wp_unslash( $_GET['uid'] ) );
    865                         $action_name = sanitize_key( wp_unslash( $_GET['confirm_action'] ) );
    866                         $result      = wp_check_account_verification_key( $key, $uid, $action_name );
     861        case 'confirmaction' :
     862                if ( ! isset( $_GET['request_id'] ) ) {
     863                        wp_die( __( 'Invalid request' ) );
     864                }
     865
     866                $request_id = (int) $_GET['request_id'];
     867
     868                if ( isset( $_GET['confirm_key'] ) ) {
     869                        $key    = sanitize_text_field( wp_unslash( $_GET['confirm_key'] ) );
     870                        $result = wp_validate_user_request_key( $request_id, $key );
    867871                } else {
    868872                        $result = new WP_Error( 'invalid_key', __( 'Invalid key' ) );
     
    870874
    871875                if ( is_wp_error( $result ) ) {
    872                         /**
    873                          * Fires an action hook when the account action was not confirmed.
    874                          *
    875                          * After running this action hook the page will die.
    876                          *
    877                          * @param WP_Error $result Error object.
    878                          */
    879                         do_action( 'account_action_failed', $result );
    880 
    881876                        wp_die( $result );
    882877                }
     
    891886                 * redirects or exits first.
    892887                 *
    893                  * @param array $result {
    894                  *     Data about the action which was confirmed.
    895                  *
    896                  *     @type string $action Name of the action that was confirmed.
    897                  *     @type string $email  Email of the user who confirmed the action.
    898                  * }
     888                 * @param int $request_id Request ID.
    899889                 */
    900                 do_action( 'account_action_confirmed', $result );
    901 
    902                 $message = '<p class="message">' . __( 'Action has been confirmed.' ) . '</p>';
    903                 login_header( '', $message );
     890                do_action( 'user_request_action_confirmed', $request_id );
     891
     892                $message = apply_filters( 'user_request_action_confirmed_message', '<p class="message">' . __( 'Action has been confirmed.' ) . '</p>', $request_id );
     893
     894                login_header( __( 'User action confirmed.' ), $message );
    904895                login_footer();
    905896                exit;
Note: See TracChangeset for help on using the changeset viewer.