This is an automated email from the ASF dual-hosted git repository. rohit pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cloudstack-primate.git
commit 6927504e40479ec971da45d0218d245700f64616 Author: Rohit Yadav <rohit.ya...@shapeblue.com> AuthorDate: Wed Feb 19 11:09:44 2020 +0530 permission: fix cookie handling to allow saml to work Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> --- src/permission.js | 5 +++++ src/store/modules/user.js | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/permission.js b/src/permission.js index 04e0925..3216a4d 100644 --- a/src/permission.js +++ b/src/permission.js @@ -15,6 +15,7 @@ // specific language governing permissions and limitations // under the License. +import Cookies from 'js-cookie' import Vue from 'vue' import router from './router' import store from './store' @@ -33,6 +34,10 @@ router.beforeEach((to, from, next) => { // start progress bar NProgress.start() to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${to.meta.title} - ${domTitle}`)) + const sessionKeyCookie = Cookies.get('sessionkey') + if (sessionKeyCookie && !Vue.ls.get(ACCESS_TOKEN)) { + Vue.ls.set(ACCESS_TOKEN, sessionKeyCookie, 24 * 60 * 60 * 1000) + } if (Vue.ls.get(ACCESS_TOKEN)) { if (to.path === '/user/login') { next({ path: '/dashboard' }) diff --git a/src/store/modules/user.js b/src/store/modules/user.js index be0e963..b2482a4 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -85,17 +85,17 @@ const user = { login(userInfo).then(response => { const result = response.loginresponse || {} - Cookies.set('account', result.account) - Cookies.set('domainid', result.domainid) - Cookies.set('role', result.type) - Cookies.set('sessionkey', result.sessionkey) - Cookies.set('timezone', result.timezone) - Cookies.set('timezoneoffset', result.timezoneoffset) - Cookies.set('userfullname', result.firstname + ' ' + result.lastname) - Cookies.set('userid', result.userid) - Cookies.set('username', result.username) - - Vue.ls.set(ACCESS_TOKEN, result.sessionkey, 60 * 60 * 1000) + Cookies.set('account', result.account, { expires: 1 }) + Cookies.set('domainid', result.domainid, { expires: 1 }) + Cookies.set('role', result.type, { expires: 1 }) + Cookies.set('sessionkey', result.sessionkey, { expires: 1 }) + Cookies.set('timezone', result.timezone, { expires: 1 }) + Cookies.set('timezoneoffset', result.timezoneoffset, { expires: 1 }) + Cookies.set('userfullname', result.firstname + ' ' + result.lastname, { expires: 1 }) + Cookies.set('userid', result.userid, { expires: 1 }) + Cookies.set('username', result.username, { expires: 1 }) + + Vue.ls.set(ACCESS_TOKEN, result.sessionkey, 24 * 60 * 60 * 1000) commit('SET_TOKEN', result.sessionkey) commit('SET_PROJECT', {}) commit('SET_ASYNC_JOB_IDS', [])