On 02/23/2012 10:10 PM, Rob Crittenden wrote:
John Dennis wrote:




This works great, particularly with patch 63. The only thing I wasn't
able to test at all is logout. Is there a way to test that as-is or will
the UI guys need to make some changes too?

rob


I just created a WIP logout button patch (attached). It seems to be working fine.

--
Petr Vobornik
From 8e4d212f0284247df67e31d552ac2fad034ef41f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20Voborn=C3=ADk?= <pvobo...@redhat.com>
Date: Fri, 24 Feb 2012 15:31:55 +0100
Subject: [PATCH] Added logout button

Logout button was added to Web UI.

Click on logout button executes session_logout command. If command succeeds or xhr stutus is 401 (unauthorized - already logged out) page is redirected to logout.html.

logout.html is a simple page with "You have been logged out" text and a link to return back to main page.

https://fedorahosted.org/freeipa/ticket/2363
---
 freeipa.spec.in        |    5 +++++
 install/ui/Makefile.am |    1 +
 install/ui/index.html  |    9 ++++++---
 install/ui/ipa.js      |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 install/ui/logout.html |   30 ++++++++++++++++++++++++++++++
 install/ui/webui.js    |    5 +++++
 6 files changed, 93 insertions(+), 4 deletions(-)
 create mode 100644 install/ui/logout.html

diff --git a/freeipa.spec.in b/freeipa.spec.in
index ee4f4838ad703c5ddd606082ac5ca23317124e9f..80f805e50cd05cdcc5752d16fcebdcd69f9b8571 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -554,6 +554,7 @@ fi
 %{_usr}/share/ipa/migration/migration.py*
 %dir %{_usr}/share/ipa/ui
 %{_usr}/share/ipa/ui/index.html
+%{_usr}/share/ipa/ui/logout.html
 %{_usr}/share/ipa/ui/*.ico
 %{_usr}/share/ipa/ui/*.css
 %{_usr}/share/ipa/ui/*.js
@@ -673,6 +674,10 @@ fi
 %ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/ca.crt
 
 %changelog
+
+* Fri Feb 24 2012 Petr Vobornik <pvobo...@redhat.com> - 2.99.0-19
+- Add Web UI logout page
+
 * Fri Feb 24 2012 Martin Kosek <mko...@redhat.com> - 2.99.0-18
 - Set min for bind-dyndb-ldap to 1.1.0-0.8.a2 to pick up new features
 
diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index d87a0944ca47e1885a9a2781e6ed03e30c662fe6..a4d083ac029446747559c63b0e039790620afb6d 100644
--- a/install/ui/Makefile.am
+++ b/install/ui/Makefile.am
@@ -38,6 +38,7 @@ app_DATA =				\
 	jquery.js			\
 	jquery.ordered-map.js 		\
 	json2.js			\
+	logout.html			\
 	navigation.js			\
 	net.js				\
 	netgroup.js 			\
diff --git a/install/ui/index.html b/install/ui/index.html
index db314331ab515b41ea17a1f7550c7444941bedd4..76cde653df9c24a7aaa26898060f4899b692892a 100644
--- a/install/ui/index.html
+++ b/install/ui/index.html
@@ -66,14 +66,17 @@
 
         <div id="header">
             <span class="header-logo">
-                 <a href="#"><img src="images/ipa-logo.png" /><img src="images/ipa-banner.png" /></a>
+                <a href="#"><img src="images/ipa-logo.png" /><img src="images/ipa-banner.png" /></a>
             </span>
             <span class="header-right">
                 <span id="loggedinas" class="header-loggedinas">
-                     <a href="#"><span id="login_header">Logged in as</span>: <strong>u...@freeipa.org</strong></a>
+                    <a href="#"><span id="login_header">Logged in as</span>: <strong>u...@freeipa.org</strong></a>
+                </span>
+                <span id="logout" class="header-loggedinas">
+                    | <a href="#logout" id="logout">Logout</a>
                 </span>
                 <span id="header-network-activity-indicator" class="network-activity-indicator">
-                     <img src="images/spinner-header.gif" />
+                    <img src="images/spinner-header.gif" />
                 </span>
             </span>
         </div>
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index a599f6a8c95ed20a63d5754c582054527251de50..0d6c5189ed90776edc9c1d1ee528566f67083fe5 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -295,7 +295,6 @@ IPA.get_credentials = function() {
         status = xhr.status;
     }
 
-
     function success_handler(data, text_status, xhr) {
         status = xhr.status;
     }
@@ -313,6 +312,52 @@ IPA.get_credentials = function() {
     return status;
 };
 
+IPA.logout = function() {
+
+    function show_mesage(message, title) {
+        var dialog = IPA.message_dialog({
+            message: message,
+            title: title | 'Logout'
+        });
+        dialog.open;
+    }
+
+    function redirect () {
+        window.location ='logout.html';
+    }
+
+    function success_handler(data, text_status, xhr) {
+
+        if (data && data.error) {
+            show_mesage(data.result.error);
+        } else {
+            redirect();
+        }
+    }
+
+    function error_handler(xhr, text_status, error_thrown) {
+        if (xhr.status === 401) {
+            redirect();
+        } else {
+            show_mesage(text_status);
+        }
+    }
+
+    var command = {
+        method: 'session_logout',
+        params: [[], {}]
+    };
+
+    var request = {
+        url: IPA.json_url || IPA.json_path + '/session_logout.json',
+        data: JSON.stringify(command),
+        success: success_handler,
+        error: error_handler
+    };
+
+    $.ajax(request);
+};
+
 /**
  * Call an IPA command over JSON-RPC.
  *
diff --git a/install/ui/logout.html b/install/ui/logout.html
new file mode 100644
index 0000000000000000000000000000000000000000..e356d2a5f9b59f0b516825fb039eaa4210dc5d98
--- /dev/null
+++ b/install/ui/logout.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>IPA: Identity Policy Audit</title>
+
+    <link rel="stylesheet" type="text/css" href="ipa.css" />
+
+</head>
+
+<body class="info-page">
+
+    <div class="container_1">
+
+        <div class="header-logo">
+            <img src="images/ipa-logo.png" /><img src="images/ipa-banner.png" />
+        </div>
+
+        <div class="textblockkrb">
+            <h1>You have been logged out</h1>
+            <p>
+                <a href="index.html">Return to main page.</a>
+            </p>
+        </div>
+
+    </div>
+
+</body>
+
+</html>
diff --git a/install/ui/webui.js b/install/ui/webui.js
index 6850ff5aa46179fd4cd4a40eb72e3a2e48cbb8f5..96fe93fbddff3e2f3526cf5a967ea1467f5d2df8 100644
--- a/install/ui/webui.js
+++ b/install/ui/webui.js
@@ -171,6 +171,11 @@ $(function() {
         $('#loggedinas a').fragment(
             {'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2);
 
+        $('#logout').click(function() {
+            IPA.logout();
+            return false;
+        });
+
         IPA.nav = create_navigation();
         IPA.nav.create();
         IPA.nav.update();
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to