Skip to content

Commit

Permalink
Fix logout with ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
aladagemre committed Feb 8, 2016
1 parent 695fb74 commit e835b5d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions sample_dropbox_folder/statique/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a id="logout" href="https://log:out@example.com/">Log Out</a>
<a id="logout" href="#" onclick="javascript:logout();">Log Out</a>
</li>
</ul>
</div>
Expand All @@ -51,9 +51,30 @@
</div>
</div>
<script type="text/javascript">
hostname = window.location.href.split("/")[2];
lourl = "http://log:out@" + hostname + "/";
document.getElementById("logout").href = lourl;
function logout() {
var hostname = window.location.href.split("/")[2];
var userAgent = navigator.userAgent.toLowerCase();

if (userAgent.indexOf("msie") != -1) {
document.execCommand("ClearAuthenticationCache", false);
}

xhr_objectCarte = null;

if(window.XMLHttpRequest)
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject)
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
alert ("Your browser doesn't support XMLHTTPREQUEST");

xhr_object.open ('GET', 'http://' + hostname, false, 'username', 'password');
xhr_object.send ("");
xhr_object = null;

document.location = 'http://' + hostname;
return false;
}
</script>
</body>
</html>

0 comments on commit e835b5d

Please sign in to comment.