ui: if session cookie exists, use it to set global session holder and invalidate it
The 19e3c0168e744a76b5e1dc24a5eafa776d342404 commit breaks SAML login and any login where redirection is used. Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> Conflicts: plugins/user-authenticators/saml2/src/org/apache/cloudstack/api/command/SAML2LoginAPIAuthenticatorCmd.java Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e8f7215b Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e8f7215b Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e8f7215b Branch: refs/heads/4.4 Commit: e8f7215b2629808dc6376f137df2a8080f9204fe Parents: d3122a1 Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Fri Mar 13 15:01:11 2015 +0530 Committer: Daan Hoogland <d...@onecht.net> Committed: Tue Mar 17 13:20:46 2015 +0100 ---------------------------------------------------------------------- ui/scripts/cloudStack.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e8f7215b/ui/scripts/cloudStack.js ---------------------------------------------------------------------- diff --git a/ui/scripts/cloudStack.js b/ui/scripts/cloudStack.js index 367a0df..7e67850 100644 --- a/ui/scripts/cloudStack.js +++ b/ui/scripts/cloudStack.js @@ -137,14 +137,22 @@ } return cookieValue; }; - g_sessionKey = unBoxCookieValue('JSESSIONID'); + unBoxCookieValue('sessionkey'); + // if sessionkey cookie exists use this to set g_sessionKey + // and destroy sessionkey cookie + if ($.cookie('sessionkey')) { + g_sessionKey = $.cookie('sessionkey'); + $.cookie('sessionkey', null); + } else { + g_sessionKey = unBoxCookieValue('JSESSIONID'); + } 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'); + g_timezone = unBoxCookieValue('timezone'); } else { //single-sign-on (bypass login screen) g_mySession = $.cookie('JSESSIONID'); g_sessionKey = encodeURIComponent(g_loginResponse.sessionkey); @@ -397,6 +405,7 @@ g_loginCmdText = null; $.cookie('JSESSIONID', null); + $.cookie('sessionkey', null); $.cookie('username', null); $.cookie('account', null); $.cookie('domainid', null); @@ -423,6 +432,7 @@ samlLoginAction: function(args) { $.cookie('JSESSIONID', null); + $.cookie('sessionkey', null); $.cookie('username', null); $.cookie('account', null); $.cookie('domainid', null);