Changeset 11046
- Timestamp:
- 06/21/2021 05:36:48 AM (2 years ago)
- Location:
- sites/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/common/includes/wporg-sso/class-wporg-sso.php
r10980 r11046 133 133 * @return string Safe redirect URL from $_REQUEST['redirect_to'] 134 134 */ 135 protected function _get_safer_redirect_to( ) {135 protected function _get_safer_redirect_to( $default = 'https://wordpress.org/' ) { 136 136 // Setup a default redirect to URL, with a safe version to only change if validation succeeds below. 137 $redirect_to = ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'logout', 'loggedout' ) ) ? '/loggedout/' : 'https://wordpress.org/';137 $redirect_to = ! empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'logout', 'loggedout' ) ) ? '/loggedout/' : $default; 138 138 139 139 if ( ! empty( $_REQUEST['redirect_to'] ) && is_string( $_REQUEST['redirect_to'] ) ) { -
sites/trunk/common/includes/wporg-sso/wp-plugin.php
r10979 r11046 17 17 */ 18 18 public $valid_sso_paths = array( 19 'root' => '/', 20 'robots' => '/robots\.txt', 21 'checkemail' => '/checkemail', 22 'loggedout' => '/loggedout', 23 'lostpassword' => '/lostpassword(/(?P<user>[^/]+))?', 24 'linkexpired' => '/linkexpired(/(?P<reason>register|lostpassword)/(?P<user>[^/]+))?', 25 'oauth' => '/oauth', 26 27 // Only for logged in users, but prior to cookies. 28 'updated-tos' => '/updated-policies', 29 ); 30 31 /** 32 * List of additional valid paths on login.wordpress.org for logged in requests. 33 * @var array 34 */ 35 public $valid_sso_paths_logged_in = array( 36 'logout' => '/logout', 37 ); 38 39 /** 40 * List of additional valid paths on login.wordpress.org for logged-out requests. 41 * @var array 42 */ 43 public $valid_sso_paths_registration = array( 19 'root' => '/', 20 'robots' => '/robots\.txt', 21 'checkemail' => '/checkemail', 22 'loggedout' => '/loggedout', 23 'lostpassword' => '/lostpassword(/(?P<user>[^/]+))?', 24 'linkexpired' => '/linkexpired(/(?P<reason>[^/]+)(/(?P<user>[^/]+))?)?', 25 'oauth' => '/oauth', 26 27 // Primarily for logged in users. 28 'updated-tos' => '/updated-policies', 29 'logout' => '/logout', 30 31 // Primarily for logged out users. 44 32 'pending-profile' => '/register/create-profile(/(?P<profile_user>[^/]+)/(?P<profile_key>[^/]+))?', 45 33 'pending-create' => '/register/create(/(?P<confirm_user>[^/]+)/(?P<confirm_key>[^/]+))?', … … 220 208 // Not in list of targeted domains, not interested, bail out 221 209 return; 222 }223 224 // Extend paths which are only available for logged in users.225 if ( is_user_logged_in() ) {226 $this->valid_sso_paths = array_merge(227 $this->valid_sso_paths,228 $this->valid_sso_paths_logged_in229 );230 231 // Extend registration paths only when registration is open.232 } elseif ( 'user' === get_site_option( 'registration', 'none' ) ) {233 $this->valid_sso_paths = array_merge(234 $this->valid_sso_paths,235 $this->valid_sso_paths_registration236 );237 210 } 238 211 … … 339 312 return; 340 313 } 341 } else if ( is_user_logged_in() && 'logout' == self::$matched_route ) {342 // No redirect, ask the user if they really want to log out.343 return;344 } else if ( 'robots' === self::$matched_route ) {345 // No redirect, just display robots.346 } else if ( is_user_logged_in() ) {347 // Otherwise, redirect to the their profile.348 $this->_redirect_to_source_or_profile();349 314 } 350 315 } elseif ( … … 462 427 */ 463 428 protected function _redirect_to_source_or_profile() { 464 $redirect = $this->_get_safer_redirect_to( );429 $redirect = $this->_get_safer_redirect_to( false ); 465 430 466 431 if ( $redirect ) { -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/linkexpired.php
r10898 r11046 14 14 <h2 class="center"><?php _e( 'Link Expired', 'wporg' ); ?></h2> 15 15 16 <p class="center"><?php _e( "The link you've followed has expired.", 'wporg' ); ?></p>17 18 16 <?php 19 17 if ( 'register' == $reason && $user ) { 20 echo '<p class="center"><a href="' . esc_url( home_url( '/register/' . urlencode( $user ) ) ) . '">' . 21 sprintf( 22 /* translators: %s: An account name. */ 23 __( 'Start over, and register %s.', 'wporg' ), 24 '<code>' . esc_html( $user ) . '</code>' 25 ) . 26 '</a></p>'; 18 echo '<p class="center">' . __( "The link you've followed has expired.", 'wporg' ) . '</p>'; 19 20 echo '<p class="center"><a href="' . esc_url( home_url( '/register/' . urlencode( $user ) ) ) . '">' . 21 sprintf( 22 /* translators: %s: An account name. */ 23 __( 'Start over, and register %s.', 'wporg' ), 24 '<code>' . esc_html( $user ) . '</code>' 25 ) . 26 '</a></p>'; 27 27 } elseif ( 'lostpassword' == $reason && $user ) { 28 echo '<p class="center">' . __( "The link you've followed has expired.", 'wporg' ) . '</p>'; 28 29 echo '<p class="center"><a href="' . esc_url( home_url( '/lostpassword/' . urlencode( $user ) ) ) . '">' . 29 30 __( 'Reset your password.', 'wporg' ) . 30 31 '</a></p>'; 32 } elseif ( 'account-created' === $reason ) { 33 echo '<p class="center">' . __( "That account has already been created.", 'wporg' ) . '</p>'; 34 35 echo '<p class="center"><a href="' . add_query_arg( 'user', $user, home_url() ) . '">' . __( 'Please login to continue.', 'wporg' ) . '</a></p>'; 36 37 echo '<p class="center"><a href="' . esc_url( home_url( '/lostpassword/' . urlencode( $user ) ) ) . '">' . 38 __( 'Reset your password.', 'wporg' ) . 39 '</a></p>'; 40 41 } elseif ( 'register-logged-in' === $reason ) { 42 echo '<p class="center">' . sprintf( 43 __( 'Please do not make multiple WordPress.org accounts. Please read the <a href="%s">Forum Guidelines</a> for more information.', 'wporg' ), 44 'https://wordpress.org/support/guidelines/#do-not-create-multiple-accounts-sockpuppets' 45 ) . '</p>'; 46 47 echo '<p class="center">' . __( 'Please logout, and folow the link again to complete the registration.', 'wporg' ) . '</p>'; 48 49 echo '<p class="center">' . sprintf( 50 /* translators: %s: logout URL */ 51 __( 'Do you really want to <a href="%s">log out</a>?', 'wporg' ), 52 wp_logout_url() 53 ) . '</p>'; 54 55 } else { 56 echo '<p class="center">' . __( "The link you've followed has expired.", 'wporg' ) . '</p>'; 31 57 } 32 58 ?> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/login.php
r11044 r11046 11 11 <?php 12 12 wp_login_form( [ 13 // pre-fill the last user if their session has simply timed out.14 'value_username' => wp_parse_auth_cookie()['username'] ?? ''13 // pre-fill with a given username, or with the last user if their session has simply timed out. 14 'value_username' => $_REQUEST['user'] ?? ( wp_parse_auth_cookie()['username'] ?? '' ) 15 15 ] ); 16 16 ?> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/logout.php
r7696 r11046 6 6 */ 7 7 8 // This will be validated at redirect time. 9 $redirect_to = !empty( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : home_url( '/loggedout/' ); 10 11 if ( ! is_user_logged_in() ) { 12 wp_safe_redirect( $redirect_to ); 13 exit; 14 } 15 8 16 get_header(); 9 17 ?> … … 11 19 12 20 <?php 13 14 // This will be validated at redirect time.15 $redirect_to = !empty( $_GET['redirect_to'] ) ? $_GET['redirect_to'] : home_url( '/loggedout/' );16 21 17 22 printf( -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-create.php
r10981 r11046 26 26 } 27 27 28 // Already logged in.. Warn about duplicate accounts, etc. 29 if ( is_user_logged_in() && $activation_user != wp_get_current_user()->user_login ) { 30 wp_safe_redirect( home_url( '/linkexpired/register-logged-in' ) ); 31 exit; 32 } 33 28 34 $can_access = false; 29 35 if ( $pending_user && $pending_user['user_activation_key'] && ! $pending_user['created'] ) { … … 42 48 } 43 49 } elseif ( $pending_user && $pending_user['created'] ) { 44 wp_safe_redirect( 'https://wordpress.org/support/');50 wp_safe_redirect( home_url( '/linkexpired/account-created/' . urlencode( $pending_user['user_login'] ) ) ); 45 51 die(); 46 52 } 47 53 48 54 if ( ! $can_access ) { 49 wp_safe_redirect( '/ ' );55 wp_safe_redirect( '/linkexpired' ); 50 56 die(); 51 57 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/pending-profile.php
r10981 r11046 8 8 $sso = WPOrg_SSO::get_instance(); 9 9 10 10 // Migrate to cookies. 11 11 if ( !empty( $sso::$matched_route_params['profile_user'] ) ) { 12 12 setcookie( 'wporg_profile_user', $sso::$matched_route_params['profile_user'], time()+DAY_IN_SECONDS, '/register/', 'login.wordpress.org', true, true ); … … 21 21 22 22 $pending_user = wporg_get_pending_user( $profile_user ); 23 24 // Already logged in.. Warn about duplicate accounts, etc. 25 if ( is_user_logged_in() ) { 26 wp_safe_redirect( home_url( '/linkexpired/register-logged-in' ) ); 27 exit; 28 } 23 29 24 30 $can_access = false; … … 37 43 38 44 if ( $can_access && $pending_user['created'] ) { 39 wp_safe_redirect( 'https://wordpress.org/support/');45 wp_safe_redirect( home_url( '/linkexpired/account-created/' . urlencode( $pending_user['user_login'] ) ) ); 40 46 die(); 41 47 } elseif ( ! $can_access ) { -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-login/register.php
r10928 r11046 13 13 if ( ! $user_login && ! empty( WP_WPOrg_SSO::$matched_route_params['user'] ) ) { 14 14 $user_login = trim( WP_WPOrg_SSO::$matched_route_params['user'] ); 15 } 16 17 // Already logged in.. Warn about duplicate accounts, etc. 18 if ( is_user_logged_in() ) { 19 wp_safe_redirect( home_url( '/linkexpired/register-logged-in' ) ); 20 exit; 15 21 } 16 22
Note: See TracChangeset
for help on using the changeset viewer.