On 12/20/2011 7:16 PM, Endi Sukma Dewata wrote:
The JSON server has been modified to return the principal name
in all responses. The UI has been modified to keep the principal
obtained during whoami operation and check the principal returned
in subsequent operations. If the principal changes the UI will
reload itself.

Ticket #1400

New patch to fix infinite reload problem with test fixtures.

--
Endi S. Dewata
From ce08f76bb51e3d92aeb13fc72a5252b4e77d920c Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Tue, 20 Dec 2011 18:09:20 -0600
Subject: [PATCH] Reload UI when the user changes.

The JSON server has been modified to return the principal name
in all responses. The UI has been modified to keep the principal
obtained during whoami operation and check the principal returned
in subsequent operations. If the principal changes the UI will
reload itself.

Ticket #1400
---
 install/ui/ipa.js      |    4 ++++
 ipaserver/rpcserver.py |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 5d59a89a456a4a55364121d1cd06b3a3edad0bed..080f4836d03f59ba5657265f40e040f06a64f1a0 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -120,6 +120,7 @@ var IPA = function() {
             },
             on_success: function(data, text_status, xhr) {
                 that.whoami = data.result[0];
+                that.principal = that.whoami.krbprincipalname[0];
             }
         }));
 
@@ -419,6 +420,9 @@ IPA.command = function(spec) {
                     message: data ? xhr.statusText : IPA.get_message('errors.no_response', 'No response')
                 });
 
+            } else if (IPA.principal && data.principal && IPA.principal !== data.principal) {
+                window.location.reload();
+
             } else if (data.error) {
                 // error_handler() calls IPA.hide_activity_icon()
                 error_handler.call(this, xhr, text_status,  /* error_thrown */ {
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index e12f2706e99d4108c52be4daccedc0ed684eae54..2bfb8ea60b0c4bbb136f5d11c8528470a75abcf4 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -469,6 +469,7 @@ class jsonserver(WSGIExecutioner):
             result=result,
             error=error,
             id=_id,
+            principal=unicode(context.principal),
         )
         response = json_encode_binary(response)
         return json.dumps(response, sort_keys=True, indent=4)
-- 
1.7.5.1

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

Reply via email to