Making WordPress.org


Ignore:
Timestamp:
01/06/2014 06:20:18 PM (13 years ago)
Author:
nacin
Message:

Trac: Auth checks. Mimic WP heartbeat auth checks on Trac. Check if we're still logged in every five minutes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/trac.wordpress.org/templates/site.html

    r211 r215  
    4242        <script src="//openatd.svn.wordpress.org/atd-jquery/scripts/csshttprequest.js"></script>
    4343        <link rel="stylesheet" type="text/css" href="//openatd.svn.wordpress.org/atd-jquery/css/atd.css" media="screen" />
     44        <link py:if="req.session['authenticated']" rel="stylesheet" href="//s.w.org/wp-includes/css/wp-auth-check.css?ver=3.9-alpha" type="text/css" media="all" />
    4445</head>
    4546
    … …  
    177178
    178179<!--! email addresses are synced with Trac from WP.org, so remove the preference pane -->
    179 <py:if test="req.environ['PATH_INFO'] == '/prefs' and project_slug == 'core'">
     180<py:if test="req.environ['PATH_INFO'] == '/prefs' and project_slug == 'core' and req.session['email'] and req.session['authenticated']">
    180181        <py:match path="div[@id='content' and @class='prefs']/div[@id='tabcontent']" once="true">
    181182                <div id="tabcontent">
    … …  
    223224        } catch(err) {}</script>
    224225        </py:if>
     226
     227        <!--! Trac auth check -->
     228        <py:if test="req.session['authenticated']">
     229                <!--TRAC_WP_USER_IS_LOGGED_IN-->
     230                <div id="wp-auth-check-wrap" class="hidden fallback">
     231                        <div id="wp-auth-check-bg"></div>
     232                        <div id="wp-auth-check">
     233                                <div class="wp-auth-check-close" tabindex="0" title="Close"></div>
     234                                <div class="wp-auth-fallback"><p><b class="wp-auth-fallback-expired" tabindex="0">Session expired</b></p><p><a href="https://make.wordpress.org/core/wp-login.php" target="_blank">Please log in again.</a> The login page will open in a new window. After logging in you can close it and return to this page.</p>
     235                                </div>
     236                        </div>
     237                </div>
     238                <script>
     239                function wp_trac_auth_check() {
     240                        $.ajax( '${href('/')}' ).success( function( data ) {
     241                                var addClass = -1 !== data.indexOf( '<!--TRAC_WP_USER_IS_LOGGED_IN-->' );
     242                                $( '#wp-auth-check-wrap' ).toggleClass( 'hidden', addClass );
     243                        });
     244                }
     245                jQuery(document).ready(function( $ ) {
     246                        $('.wp-auth-check-close').click( function() {
     247                                $( '#wp-auth-check-wrap' ).addClass( 'hidden' );
     248                        });
     249                        window.setInterval( wp_trac_auth_check, 5 * 60 * 1000 );
     250                });
     251                </script>
     252        </py:if>
    225253</body>
    226254
Note: See TracChangeset for help on using the changeset viewer.