mirror of https://github.com/apache/cloudstack.git
permission: fix cookie handling to allow saml to work
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
83af66ca87
commit
4a2e63db17
|
|
@ -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' })
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
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, 60 * 60 * 1000)
|
||||
Vue.ls.set(ACCESS_TOKEN, result.sessionkey, 24 * 60 * 60 * 1000)
|
||||
commit('SET_TOKEN', result.sessionkey)
|
||||
commit('SET_PROJECT', {})
|
||||
commit('SET_ASYNC_JOB_IDS', [])
|
||||
|
|
|
|||
Loading…
Reference in New Issue