in prevision for django-1.7, rename our local auth module into localauth to avoid...
[myslice.git] / localauth / static / js / logout.js
diff --git a/localauth/static/js/logout.js b/localauth/static/js/logout.js
new file mode 100644 (file)
index 0000000..3419b9d
--- /dev/null
@@ -0,0 +1,13 @@
+/* retrieve username from the button that is clicked, the one named 'logout' 
+   and that is expected to have the 'username' attribute */
+function logout () {
+    var username=$(this).data('username');
+    var msg="Are you sure you want to logout as " + username + " ?";
+    /* redirect to /logout, see urls.py */
+    if (confirm(msg)){
+        localStorage.clear();
+        window.location="/logout/";
+    }
+}
+/* attach this function to the logout button */
+$(document).ready(function() { $('#logout').click(logout); $('#logoutbtn').click(logout); });