brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/2] brooklyn-ui git commit: Improve logout script
Date Wed, 24 Aug 2016 16:51:32 GMT
Repository: brooklyn-ui
Updated Branches:
  refs/heads/master 0ebdb5c99 -> ef66e69e5


Improve logout script

- fix logout for Internet Explorer
- use get call to logout


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/52ca6855
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/52ca6855
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/52ca6855

Branch: refs/heads/master
Commit: 52ca6855a609d44787d56be9539204d17bcec42b
Parents: 0ebdb5c
Author: Valentin Aitken <bostko@gmail.com>
Authored: Wed Aug 3 22:58:45 2016 +0300
Committer: Valentin Aitken <bostko@gmail.com>
Committed: Wed Aug 24 14:33:33 2016 +0300

----------------------------------------------------------------------
 .../webapp/assets/js/util/brooklyn-utils.js     | 23 ++++++++++----------
 src/main/webapp/logout_redirect.html            | 14 ++++++++++++
 2 files changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/52ca6855/src/main/webapp/assets/js/util/brooklyn-utils.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/util/brooklyn-utils.js b/src/main/webapp/assets/js/util/brooklyn-utils.js
index 5012363..92ec2d2 100644
--- a/src/main/webapp/assets/js/util/brooklyn-utils.js
+++ b/src/main/webapp/assets/js/util/brooklyn-utils.js
@@ -175,17 +175,16 @@ define([
     };
 
     Util.logout = function logout() {
-        $.ajax({
-            type: "POST",
-            dataType: "text",
-            url: "/v1/logout",
-            success: function() {
-                window.location.replace("/");
-            },
-            failure: function() {
-                window.location.replace("/");
-            }
-        });
+        var ua = window.navigator.userAgent;
+        if (ua.indexOf("MSIE ") >= 0 || ua.indexOf(" Edge/") >= 0 || ua.indexOf(" Trident/")
>= 0) {
+            document.execCommand('ClearAuthenticationCache', 'false');
+            window.location.replace('/');
+        } else {
+            $('<form action="' + '/logout_redirect.html' + '" method="POST" id="redirectForm">'
+
+                '<input type="hidden" name="acme" value="acme"/>' +
+                '</form>').appendTo($(document.body))
+                .submit();
+        }
     }
 
     Util.setSelectionRange = function (input, selectionStart, selectionEnd) {
@@ -216,7 +215,7 @@ define([
 
     $("#logout-link").on("click", function (e) {
         e.preventDefault();
-        Util.logout()
+        Util.logout();
         return false;
     });
 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/52ca6855/src/main/webapp/logout_redirect.html
----------------------------------------------------------------------
diff --git a/src/main/webapp/logout_redirect.html b/src/main/webapp/logout_redirect.html
new file mode 100644
index 0000000..2699532
--- /dev/null
+++ b/src/main/webapp/logout_redirect.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>Title</title>
+</head>
+<body>
+<script>
+    var a=new window.XMLHttpRequest;
+    a.open('POST','/logout',0,'user','wrong'+(new Date).getTime().toString());a.send('');
+    window.location.href='/';
+</script>
+</body>
+</html>
\ No newline at end of file


Mime
View raw message