diff --git a/freeipa.spec.in b/freeipa.spec.in index 3609bddf0..90c8e9f8d 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -555,6 +555,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 @@ -674,6 +675,9 @@ fi %ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/ca.crt %changelog +* Wed Feb 29 2012 Petr Vobornik - 2.99.0-20 +- Add Web UI logout page + * Mon Feb 27 2012 Rob Crittenden - 2.99.0-19 - Add Requires to ipa-client on oddjob-mkhomedir diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am index d87a0944c..a4d083ac0 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 db314331a..6b1be869b 100644 --- a/install/ui/index.html +++ b/install/ui/index.html @@ -66,14 +66,17 @@ diff --git a/install/ui/ipa.js b/install/ui/ipa.js index d1bb04210..0afa4f097 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,51 @@ IPA.get_credentials = function() { return status; }; +IPA.logout = function() { + + function show_error(message) { + var dialog = IPA.message_dialog({ + message: message, + title: IPA.messages.login.logout_error + }); + dialog.open(); + } + + function redirect () { + window.location = 'logout.html'; + } + + function success_handler(data, text_status, xhr) { + if (data && data.error) { + show_error(data.error.message); + } else { + redirect(); + } + } + + function error_handler(xhr, text_status, error_thrown) { + if (xhr.status === 401) { + redirect(); + } else { + show_error(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 000000000..e356d2a5f --- /dev/null +++ b/install/ui/logout.html @@ -0,0 +1,30 @@ + + + + + IPA: Identity Policy Audit + + + + + + + +
+ + + +
+

You have been logged out

+

+ Return to main page. +

+
+ +
+ + + + diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 29880b2eb..e5b4be169 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -110,7 +110,9 @@ }, "false": "False", "login": { - "header": "Logged In As" + "header": "Logged In As", + "logout": "Logout", + "logout_error": "Logout error" }, "objects": { "aci": { diff --git a/install/ui/test/data/session_logout.json b/install/ui/test/data/session_logout.json new file mode 100644 index 000000000..13410c6e2 --- /dev/null +++ b/install/ui/test/data/session_logout.json @@ -0,0 +1,7 @@ +{ + "error": null, + "id": null, + "result": { + "result": null + } +} \ No newline at end of file diff --git a/install/ui/webui.js b/install/ui/webui.js index b8394d289..5d32e7977 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -170,6 +170,11 @@ $(function() { $('#loggedinas a').fragment( {'user-facet': 'details', 'user-pkey': IPA.whoami_pkey}, 2); + $('#logout').click(function() { + IPA.logout(); + return false; + }).text(IPA.messages.login.logout); + IPA.nav = create_navigation(); IPA.nav.create(); IPA.nav.update(); diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index c346b4428..4ccbe5cd6 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -245,7 +245,9 @@ class i18n_messages(Command): }, "false": _("False"), "login": { - "header": _("Logged In As") + "header": _("Logged In As"), + "logout": _("Logout"), + "logout_error": _("Logout error"), }, "objects": { "aci": {