summaryrefslogtreecommitdiffstats
path: root/install/ui/ipa.js
diff options
context:
space:
mode:
authorPetr Voborník <pvoborni@redhat.com>2012-02-24 15:31:55 +0100
committerRob Crittenden <rcritten@redhat.com>2012-02-28 23:58:51 -0500
commit87901ed7098dff72e4a62dfe582c2b83439b7280 (patch)
tree9fcf4354796ac72d68b48ead826f6b3c8db0a818 /install/ui/ipa.js
parenta5a55ceff3822ede55ad817ede0da5712fb75651 (diff)
downloadfreeipa-87901ed7098dff72e4a62dfe582c2b83439b7280.tar.gz
freeipa-87901ed7098dff72e4a62dfe582c2b83439b7280.tar.xz
freeipa-87901ed7098dff72e4a62dfe582c2b83439b7280.zip
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
Diffstat (limited to 'install/ui/ipa.js')
-rw-r--r--install/ui/ipa.js46
1 files changed, 45 insertions, 1 deletions
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.
*