Changeset 9146 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-create.php
- Timestamp:
- 09/23/2019 03:52:23 AM (6 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-create.php
r9139 r9146 1 1 <?php 2 2 /** 3 * The post- register profile-fieldsTemplate3 * The post-email-confirm Template 4 4 * 5 5 * @package wporg-login 6 6 */ 7 7 8 // 'register-confirm' => '/register/confirm/(?P<confirm_user>[^/]+)/(?P<confirm_key>[^/]+)', 8 $activation_user = WP_WPOrg_SSO::$matched_route_params['confirm_user'] ?? false; 9 $activation_key = WP_WPOrg_SSO::$matched_route_params['confirm_key'] ?? false; 9 10 10 $confirm_user = isset( WP_WPOrg_SSO::$matched_route_params['confirm_user'] ) ? WP_WPOrg_SSO::$matched_route_params['confirm_user'] : false; 11 $confirm_key = isset( WP_WPOrg_SSO::$matched_route_params['confirm_key'] ) ? WP_WPOrg_SSO::$matched_route_params['confirm_key'] : false; 11 $pending_user = wporg_get_pending_user( $activation_user ); 12 if ( ! $pending_user ) { 13 // TODO: add a handler for "Link is expired". The pending user record has been purged. 14 // See Line 33 below for the second case where this is needed. 15 } 12 16 13 $can_access = true; 14 if ( 15 $confirm_user && $confirm_key && 16 ( $user = get_user_by( 'login', $confirm_user ) ) && 17 $user->exists() 18 ) { 19 wp_set_current_user( $user->ID ); 17 $can_access = false; 18 if ( $pending_user && $pending_user['user_activation_key'] && ! $pending_user['created'] ) { 19 $expiration_duration = WEEK_IN_SECONDS; // Time that the user has to confirm the account. 20 20 21 $user_activation_key = $user->user_activation_key; 22 if ( ! $user_activation_key ) { 23 // The activation key may not be in the cached user object, so we'll fetch it manually. 24 $user_activation_key = $wpdb->get_var( $wpdb->prepare( "SELECT user_activation_key FROM {$wpdb->users} WHERE ID = %d", $user->ID ) ); 21 list( $user_request_time, $hashed_activation_key ) = explode( ':', $pending_user['user_activation_key'], 2 ); 22 $expiration_time = $user_request_time + $expiration_duration; 23 24 $hash_is_correct = wp_check_password( $activation_key, $hashed_activation_key ); 25 26 if ( $hash_is_correct && time() < $expiration_time ) { 27 $can_access = true; 28 } elseif ( $hash_is_correct ) { 29 // TODO: Add a handler for "Link is expired". 30 // For now, ignore the expiry date on the email links. 31 // This URL is invalidated once the user is created anyway. 32 $can_access = true; 25 33 } 26 27 list( $reset_time, $hashed_activation_key ) = explode( ':', $user_activation_key, 2 ); 28 29 if ( empty( $wp_hasher ) ) { 30 require_once ABSPATH . WPINC . '/class-phpass.php'; 31 $wp_hasher = new PasswordHash( 8, true ); 32 } 33 $can_access = $wp_hasher->CheckPassword( $confirm_key, $hashed_activation_key ); 34 35 // Keys are only valid for 7 days (or until used) 36 $can_access = $can_access && ( $reset_time + ( 7*DAY_IN_SECONDS ) > time() ); 34 } elseif ( $pending_user && $pending_user['created'] ) { 35 wp_safe_redirect( 'https://wordpress.org/support/' ); 36 die(); 37 37 } 38 38 39 39 if ( ! $can_access ) { 40 wp_set_current_user( 0 );41 40 wp_safe_redirect( "/" ); 42 41 die(); 43 } elseif ( !empty( $_POST['user_pass'] ) ) { 42 } 43 44 if ( isset( $_POST['user_pass'] ) ) { 44 45 $user_pass = wp_unslash( $_POST['user_pass'] ); 46 47 if ( $pending_user && ! $pending_user['created'] ) { 48 $user = wporg_login_create_user_from_pending( $pending_user, $user_pass ); 49 if ( $user ) { 50 wp_set_current_user( $user->ID ); 51 wp_set_auth_cookie( $user->ID, true ); 52 } 53 } 45 54 46 55 wporg_login_save_profile_fields(); 47 56 48 add_filter( 'send_password_change_email', '__return_false' ); 49 if ( wp_update_user( wp_slash( array( 50 'ID' => $user->ID, 51 'user_pass' => $user_pass, 52 ) ) ) ) { 53 $wpdb->update( $wpdb->users, array( 'user_activation_key' => '' ), array( 'ID' => $user->ID ) ); 54 wp_set_auth_cookie( $user->ID, true ); 55 wp_safe_redirect( 'https://wordpress.org/support/' ); 56 die(); 57 } 57 wp_safe_redirect( 'https://wordpress.org/support/' ); 58 die(); 58 59 } 59 60 … … 86 87 <!-- <p class="description indicator-hint"><?php _e( 'Hint: The password should be at least twelve characters long. To make it stronger, use upper and lower case letters, numbers, and symbols like ! " ? $ % ^ & ).', 'wporg' ); ?></p> --> 87 88 88 <?php include __DIR__ . '/partials/register-profilefields.php'; ?> 89 <?php 90 $fields = &$pending_user['meta']; 91 include __DIR__ . '/partials/register-profilefields.php'; 92 ?> 89 93 90 94 <p class="login-submit">
Note: See TracChangeset
for help on using the changeset viewer.