Making WordPress.org


Ignore:
Timestamp:
09/23/2019 03:52:23 AM (6 years ago)
Author:
dd32
Message:

Login: Store user registrations in a custom table until they confirm their email address (at which time, we create the actual wp_users records).

This is to combat the significant number of unconfirmed accounts that are created, by separating them it's easier to purge them periodically, but also easier to add extra anti-spam checks as needed.

See #4739.

File:
1 copied

Legend:

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

    r9139 r9146  
    11<?php
    22/**
    3  * The post-register profile-fields Template
     3 * The post-pending-email-confirm profile-fields Template
    44 *
    55 * @package wporg-login
    66 */
    77
    8 $profile_user = isset( WP_WPOrg_SSO::$matched_route_params['profile_user'] ) ? WP_WPOrg_SSO::$matched_route_params['profile_user'] : false;
    9 $profile_nonce  = isset( WP_WPOrg_SSO::$matched_route_params['profile_nonce'] ) ? WP_WPOrg_SSO::$matched_route_params['profile_nonce'] : false;
     8$profile_user = WP_WPOrg_SSO::$matched_route_params['profile_user'] ?? false;
     9$profile_key  = WP_WPOrg_SSO::$matched_route_params['profile_key']  ?? false;
     10
     11$pending_user = wporg_get_pending_user( $profile_user );
    1012
    1113$can_access = false;
    12 if (
    13     $profile_user && $profile_nonce &&
    14     ( $user = get_user_by( 'login', $profile_user ) ) &&
    15     $user->exists()
    16 ) {
    17     wp_set_current_user( $user->ID );
    18     $can_access = wp_verify_nonce( $profile_nonce, 'login-register-profile-edit' );
     14if ( $pending_user && $pending_user['user_profile_key'] ) {
     15    $expiration_duration = DAY_IN_SECONDS; // The profile-edit screen is short lived.
     16
     17    list( $user_request_time, $hashed_profile_key ) = explode( ':', $pending_user['user_profile_key'], 2 );
     18    $expiration_time                                = $user_request_time + $expiration_duration;
     19
     20    $hash_is_correct = wp_check_password( $profile_key, $hashed_profile_key );
     21
     22    if ( $hash_is_correct && time() < $expiration_time ) {
     23        $can_access = true;
     24    }
    1925}
    2026
    21 if ( ! $can_access ) {
    22     wp_set_current_user( 0 );
     27if ( $can_access && $pending_user['created']  ) {
     28    wp_safe_redirect( 'https://wordpress.org/support/' );
     29    die();
     30} elseif ( ! $can_access ) {
    2331    wp_safe_redirect( '/' );
    2432    die();
    2533}
    2634
    27 wporg_login_save_profile_fields();
    28 
     35if ( wporg_login_save_profile_fields( $pending_user ) ) {
     36    // re-fetch the user, it's probably changed.
     37    $pending_user = wporg_get_pending_user( $profile_user );
     38}
    2939wp_enqueue_script( 'wporg-registration' );
    3040
     
    4757<form name="registerform" id="registerform" action="" method="post">
    4858
    49     <?php include __DIR__ . '/partials/register-profilefields.php'; ?>
     59    <?php
     60        $fields = &$pending_user['meta'];
     61        include __DIR__ . '/partials/register-profilefields.php';
     62    ?>
    5063
    5164    <p class="login-submit">
Note: See TracChangeset for help on using the changeset viewer.