Make WordPress Core

Changeset 23805 for trunk/wp-login.php


Ignore:
Timestamp:
03/27/2013 08:43:11 AM (11 years ago)
Author:
azaozz
Message:

Logged out warnings: add fallback text dialog for:

  • The login page has "X-Frame-Options: DENY" header.
  • Cross-domain when displaying on the front-end on multisite with domain mapping.
  • The site forces ssl login but not ssl admin.

Add onbeforeunload prompt to counter (frame-busting) JS redirects. Move the JS and CSS into separate files. See #23295.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-login.php

    r23691 r23805  
    4949
    5050    // Shake it!
    51     $shake_error_codes = array( 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
     51    $shake_error_codes = array( 'interim_login_error', 'empty_password', 'empty_email', 'invalid_email', 'invalidcombo', 'empty_username', 'invalid_username', 'incorrect_password' );
    5252    $shake_error_codes = apply_filters( 'shake_error_codes', $shake_error_codes );
    5353
    54     if ( ! $interim_login && $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
     54    if ( $shake_error_codes && $wp_error->get_error_code() && in_array( $wp_error->get_error_code(), $shake_error_codes ) )
    5555        add_action( 'login_head', 'wp_shake_js', 12 );
    5656
     
    101101        $login_header_url = '#';
    102102        $classes[] = 'interim-login';
     103        ?>
     104        <style type="text/css">html{background-color: transparent;}</style>
     105        <?php
     106
     107        if ( 'success' ===  $interim_login )
     108            $classes[] = 'interim-login-success';
    103109    }
    104110
     
    625631        if ( $interim_login ) {
    626632            $message = '<p class="message">' . __('You have logged in successfully.') . '</p>';
     633            $interim_login = 'success';
    627634            login_header( '', $message ); ?>
    628635            </div>
     
    649656
    650657    $errors = $user;
    651     // Clear errors if loggedout or interim_login is set.
    652     if ( !empty($_GET['loggedout']) || $reauth || $interim_login )
     658    // Clear errors if loggedout is set.
     659    if ( !empty($_GET['loggedout']) || $reauth )
    653660        $errors = new WP_Error();
    654661
     
    657664        $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress."));
    658665
    659     // Some parts of this script use the main login form to display a message
    660     if      ( isset($_GET['loggedout']) && true == $_GET['loggedout'] )
    661         $errors->add('loggedout', __('You are now logged out.'), 'message');
    662     elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
    663         $errors->add('registerdisabled', __('User registration is currently not allowed.'));
    664     elseif  ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
    665         $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
    666     elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
    667         $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
    668     elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
    669         $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
    670     elseif  ( $interim_login )
    671         $errors->add('expired', __('Please log in again. You will not move away from this page.'), 'message');
    672     elseif ( strpos( $redirect_to, 'about.php?updated' ) )
    673         $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' );
     666    // Clear most errors if interim login
     667    if ( $interim_login ) {
     668        $error_code = $errors->get_error_code();
     669        $errors = new WP_Error();
     670
     671        if ( $error_code ) {
     672            if ( in_array( $error_code, array( 'empty_password', 'empty_username', 'invalid_username', 'incorrect_password' ) ) )
     673                $errors->add('interim_login_error', __('<strong>ERROR</strong>: Invalid username or password.'));
     674            else
     675                $errors->add('interim_login_error_other', sprintf( __( '<strong>ERROR</strong>: Please contact the site administrator or try to <a href="%s" target="_blank">log in from a new window</a>.' ), wp_login_url() ) );
     676        } else {
     677            $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message');
     678        }
     679    } else {
     680        // Some parts of this script use the main login form to display a message
     681        if      ( isset($_GET['loggedout']) && true == $_GET['loggedout'] )
     682            $errors->add('loggedout', __('You are now logged out.'), 'message');
     683        elseif  ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
     684            $errors->add('registerdisabled', __('User registration is currently not allowed.'));
     685        elseif  ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
     686            $errors->add('confirm', __('Check your e-mail for the confirmation link.'), 'message');
     687        elseif  ( isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail'] )
     688            $errors->add('newpass', __('Check your e-mail for your new password.'), 'message');
     689        elseif  ( isset($_GET['checkemail']) && 'registered' == $_GET['checkemail'] )
     690            $errors->add('registered', __('Registration complete. Please check your e-mail.'), 'message');
     691        elseif ( strpos( $redirect_to, 'about.php?updated' ) )
     692            $errors->add('updated', __( '<strong>You have successfully updated WordPress!</strong> Please log back in to experience the awesomeness.' ), 'message' );
     693    }
    674694
    675695    // Clear any stale cookies.
Note: See TracChangeset for help on using the changeset viewer.