You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2014/08/24 16:04:59 UTC
[39/50] [abbrv] git commit: updated refs/heads/saml2 to ba68616
ui: refactor and use a unified unboxing helping method in cloudStack.js
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/21443865
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/21443865
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/21443865
Branch: refs/heads/saml2
Commit: 21443865ee267695a9c652cf8fb4f9dc19bdcb1d
Parents: b356f82
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Aug 18 04:56:54 2014 +0200
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Sat Aug 23 20:34:40 2014 +0200
----------------------------------------------------------------------
ui/scripts/cloudStack.js | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/21443865/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)