TrueHttpLogoutPatch: trac-0.10.2_basic-auth-logout.patch

File trac-0.10.2_basic-auth-logout.patch, 2.1 kB (added by conny@fuchsia.se, 2 years ago)

Adapted for v0.10.2: 'tis a hack but it solved my problem.

  • trac-0.10.2/htdocs/js/trac.js

    old new  
    129129    addLinks(container.getElementsByTagName('h' + lvl)); 
    130130  } 
    131131} 
     132 
     133function clearAuthenticationCache(page) { 
     134  // Default to a non-existing page (give error 500). 
     135  // An empty page is better, here. 
     136  if (!page) page = '.force_logout'; 
     137  try{ 
     138    var agt=navigator.userAgent.toLowerCase(); 
     139    if (agt.indexOf("msie") != -1) { 
     140      // IE clear HTTP Authentication 
     141      document.execCommand("ClearAuthenticationCache"); 
     142    } 
     143    else { 
     144      // Let's create an xmlhttp object 
     145      var xmlhttp = createXMLObject(); 
     146      // Let's prepare invalid credentials 
     147      xmlhttp.open("GET", page, true, "logout", "logout"); 
     148      // Let's send the request to the server 
     149      xmlhttp.send(""); 
     150      // Let's abort the request 
     151      xmlhttp.abort(); 
     152    } 
     153  } catch(e) { 
     154    // There was an error 
     155    return; 
     156  } 
     157} 
     158     
     159function createXMLObject() { 
     160  try { 
     161    if (window.XMLHttpRequest) { 
     162      xmlhttp = new XMLHttpRequest(); 
     163    } 
     164    // code for IE 
     165    else if (window.ActiveXObject) { 
     166      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
     167    } 
     168  } catch (e) { 
     169    xmlhttp=false 
     170  } 
     171  return xmlhttp; 
     172} 
  • trac-0.10.2/trac/web/auth.py

    old new  
    8585        if req.authname and req.authname != 'anonymous': 
    8686            yield ('metanav', 'login', 'logged in as %s' % req.authname) 
    8787            yield ('metanav', 'logout', 
    88                    html.A('Logout', href=req.href.logout())) 
     88                   html.A('Logout', href=req.href.logout(), 
     89                   onclick="clearAuthenticationCache(\'%s\')" % req.href.logout())) 
    8990        else: 
    9091            yield ('metanav', 'login', 
    9192                   html.A('Login', href=req.href.login()))