TrueHttpLogoutPatch: True_logout_patch_trunk_updated.diff

File True_logout_patch_trunk_updated.diff, 2.1 KB (added by roh, 12 years ago)

updated patch for trac svn trunk 2008/03/11

  • trac/htdocs/js/trac.js

     
    7575  window.getAncestorByTagName = function(elem, tagName) {
    7676    return $(elem).parents(tagName).get(0);
    7777  }
     78  window.clearAuthenticationCache = function(page) {
     79    // Default to a non-existing page (give error 500).
     80    // An empty page is better, here.
     81    if (!page) page = '.force_logout';
     82    try{
     83      var agt=navigator.userAgent.toLowerCase();
     84      if (agt.indexOf("msie") != -1) {
     85        // IE clear HTTP Authentication
     86        document.execCommand("ClearAuthenticationCache");
     87      }
     88      else {
     89        // Let's create an xmlhttp object
     90        var xmlhttp = createXMLObject();
     91        // Let's prepare invalid credentials
     92        xmlhttp.open("GET", page, true, "logout", "logout");
     93        // Let's send the request to the server
     94        xmlhttp.send("");
     95        // Let's abort the request
     96        xmlhttp.abort();
     97      }
     98    } catch(e) {
     99      // There was an error
     100      return;
     101    }
     102  }
     103  window.createXMLObject = function() {
     104    try {
     105      if (window.XMLHttpRequest) {
     106        xmlhttp = new XMLHttpRequest();
     107      }
     108      // code for IE
     109      else if (window.ActiveXObject) {
     110        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     111      }
     112    } catch (e) {
     113      xmlhttp=false
     114    }
     115    return xmlhttp;
     116  }
    78117
    79 })(jQuery);
    80  No newline at end of file
     118})(jQuery);
  • trac/web/auth.py

     
    8686        if req.authname and req.authname != 'anonymous':
    8787            yield ('metanav', 'login', 'logged in as %s' % req.authname)
    8888            yield ('metanav', 'logout',
    89                    tag.a('Logout', href=req.href.logout()))
     89           tag.a('Logout', href=req.href.logout(),
     90               onclick="clearAuthenticationCache(\'%s\')" % req.href.logout() ))
    9091        else:
    9192            yield ('metanav', 'login',
    9293                   tag.a('Login', href=req.href.login()))