cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [17/22] git commit: updated refs/heads/saml2 to 54986d5
Date Mon, 18 Aug 2014 09:43:42 GMT
ui: refactor and use a unified unboxing helping method in cloudStack.js

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/54986d58
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/54986d58
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/54986d58

Branch: refs/heads/saml2
Commit: 54986d58a468734c9350c44e2f06c72f42ce366e
Parents: 60e8413
Author: Rohit Yadav <rohit.yadav@shapeblue.com>
Authored: Mon Aug 18 04:56:54 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Aug 18 11:42:35 2014 +0200

----------------------------------------------------------------------
 ui/scripts/cloudStack.js | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54986d58/ui/scripts/cloudStack.js
----------------------------------------------------------------------
diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js
index edc7c21..38cf501 100644
--- a/ui/scripts/cloudStack.js
+++ b/ui/scripts/cloudStack.js
@@ -129,24 +129,25 @@
            i.e. calling listCapabilities API with g_sessionKey from $.cookie('sessionKey')
will succeed,
            then userValid will be set to true, then an user object (instead of "false") will
be returned, then login screen will be bypassed.
            */
+                    var unBoxCookieValue = function (cookieName) {
+                        var cookieValue = $.cookie(cookieName);
+                        if (cookieValue && cookieValue.length > 2 && cookieValue[0]
=== '"' && cookieValue[cookieValue.length-1] === '"') {
+                            cookieValue = cookieValue.slice(1, cookieValue.length-1);
+                            $.cookie(cookieName, cookieValue, { expires: 1 });
+                        }
+                        return cookieValue;
+                    };
                     g_mySession = $.cookie('JSESSIONID');
-                    g_sessionKey = $.cookie('sessionKey');
-                    // Unbox quotes from sessionKey cookie value
-                    if (g_sessionKey && g_sessionKey[0] === '"' && g_sessionKey[g_sessionKey.length-1]
=== '"') {
-                        g_sessionKey = g_sessionKey.slice(1, g_sessionKey.length-1);
-                        $.cookie('sessionKey', g_sessionKey, {
-                            expires: 1
-                        });
-                    }
-                    g_role = $.cookie('role');
-                    g_username = $.cookie('username');
-                    g_userid = $.cookie('userid');
-                    g_account = $.cookie('account');
-                    g_domainid = $.cookie('domainid');
-                    g_userfullname = $.cookie('userfullname');
-                    g_timezone = $.cookie('timezone');
+                    g_sessionKey = unBoxCookieValue('sessionKey');
+                    g_role = unBoxCookieValue('role');
+                    g_userid = unBoxCookieValue('userid');
+                    g_domainid = unBoxCookieValue('domainid');
+                    g_account = unBoxCookieValue('account');
+                    g_username = unBoxCookieValue('username');
+                    g_userfullname = unBoxCookieValue('userfullname');
+                    g_timezone = unBoxCookieValue('timezone');
                     if ($.cookie('timezoneoffset') != null)
-                        g_timezoneoffset = isNaN($.cookie('timezoneoffset')) ? null : parseFloat($.cookie('timezoneoffset'));
+                        g_timezoneoffset = isNaN(unBoxCookieValue('timezoneoffset')) ? null
: parseFloat(unBoxCookieValue('timezoneoffset'));
                     else
                         g_timezoneoffset = null;
                 } else { //single-sign-on	(bypass login screen)


Mime
View raw message