Making WordPress.org

Changeset 9833


Ignore:
Timestamp:
05/07/2020 02:38:43 AM (7 years ago)
Author:
dd32
Message:

Login: Registration: Move to storing the user details in cookies to provide cleaner URLs.

Location:
sites/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/common/includes/wporg-sso/wp-plugin.php

    r9832 r9833  
    161161                        if ( 'user' === get_site_option( 'registration', 'none' ) ) {
    162162                                // New "pending" registration flow.
    163                                 $this->valid_sso_paths['pending-profile']  = '/register/create-profile/(?P<profile_user>[^/]+)/(?P<profile_key>[^/]+)';
    164                                 $this->valid_sso_paths['pending-create']   = '/register/create/(?P<confirm_user>[^/]+)/(?P<confirm_key>[^/]+)';
     163                                $this->valid_sso_paths['pending-profile']  = '/register/create-profile(/(?P<profile_user>[^/]+)/(?P<profile_key>[^/]+))?';
     164                                $this->valid_sso_paths['pending-create']   = '/register/create(/(?P<confirm_user>[^/]+)/(?P<confirm_key>[^/]+))?';
    165165
    166166                                // Primary registration route.
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-create.php

    r9224 r9833  
    66 */
    77
    8 $activation_user = WP_WPOrg_SSO::$matched_route_params['confirm_user'] ?? false;
    9 $activation_key  = WP_WPOrg_SSO::$matched_route_params['confirm_key']  ?? false;
     8// Clear the pending cookies, they're no longer needed.
     9if ( isset( $_COOKIE['wporg_profile_user'] ) ) {
     10        setcookie( 'wporg_profile_user', false, time()-DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     11        setcookie( 'wporg_profile_key', false,  time()-DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     12}
     13
     14// Migrate to cookies.
     15if ( !empty( WP_WPOrg_SSO::$matched_route_params['confirm_user'] ) ) {
     16        setcookie( 'wporg_confirm_user', WP_WPOrg_SSO::$matched_route_params['confirm_user'], time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     17        setcookie( 'wporg_confirm_key',  WP_WPOrg_SSO::$matched_route_params['confirm_key'],  time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     18
     19        wp_safe_redirect( '/register/create' );
     20        die();
     21}
     22
     23$activation_user = $_COOKIE['wporg_confirm_user'] ?? false;
     24$activation_key  = $_COOKIE['wporg_confirm_key']  ?? false;
    1025
    1126$pending_user = wporg_get_pending_user( $activation_user );
    … …  
    3651
    3752if ( ! $can_access ) {
    38         wp_safe_redirect( "/" );
     53        wp_safe_redirect( '/' );
    3954        die();
    4055}
    … …  
    6176                $user = wporg_login_create_user_from_pending( $pending_user, $user_pass );
    6277                if ( $user ) {
     78                        setcookie( 'wporg_confirm_user', false, time()-DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     79                        setcookie( 'wporg_confirm_key',  false, time()-DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     80
     81                        // Log the user in
    6382                        wp_set_current_user( $user->ID );
    6483                        wp_set_auth_cookie( $user->ID, true );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-profile.php

    r9831 r9833  
    66 */
    77
    8 $profile_user = WP_WPOrg_SSO::$matched_route_params['profile_user'] ?? false;
    9 $profile_key  = WP_WPOrg_SSO::$matched_route_params['profile_key']  ?? false;
     8 // Migrate to cookies.
     9if ( !empty( WP_WPOrg_SSO::$matched_route_params['profile_user'] ) ) {
     10        setcookie( 'wporg_profile_user', WP_WPOrg_SSO::$matched_route_params['profile_user'], time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     11        setcookie( 'wporg_profile_key',  WP_WPOrg_SSO::$matched_route_params['profile_key'],  time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true );
     12
     13        wp_safe_redirect( '/register/create-profile' );
     14        die();
     15}
     16
     17$profile_user = $_COOKIE['wporg_profile_user'] ?? false;
     18$profile_key  = $_COOKIE['wporg_profile_key']  ?? false;
    1019
    1120$pending_user = wporg_get_pending_user( $profile_user );
    … …  
    2938        die();
    3039} elseif ( ! $can_access ) {
    31         wp_safe_redirect( home_url( '/linkexpired/' ) );
     40        wp_safe_redirect( home_url( '/linkexpired' ) );
    3241        die();
    3342}
Note: See TracChangeset for help on using the changeset viewer.