Add logout functionality
[matches/MCTX3420.git] / testing / MCTXWeb / public_html / static / mctx.gui.js
index fc50ed5..c57babc 100644 (file)
@@ -3,7 +3,7 @@
  */
 
 mctx = {};
-mctx.location = location.protocol + "//" + location.host;
+mctx.location = location.protocol + "//" + location.host + "/";
 mctx.api = mctx.location + "/api/";
 mctx.expected_api_version = 0;
 mctx.has_control = false;
@@ -178,6 +178,16 @@ $.fn.login = function () {
   });
 };
 
+$.fn.logout = function () {
+  $.ajax({
+    url : mctx.api + "unbind"
+  }).always(function () {
+    //Note: this only clears the nameless cookie
+    document.cookie = ""; 
+    window.location = mctx.location + "login.html";
+  });
+}
+
 $.fn.setErrorLog = function () {
   var url = mctx.api + "errorlog";
   var outdiv = this;

UCC git Repository :: git.ucc.asn.au