mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixing login, session expired and blacklisted api requests
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
e394c81f55
commit
39694aba8d
@ -25,6 +25,7 @@
|
||||
"error.release.dedicate.zone": "Failed to release dedicated zone",
|
||||
"error.session.expired": "Your session has expired.",
|
||||
"error.unable.to.reach.management.server": "Unable to reach Management Server",
|
||||
"error.unable.to.proceed": "Unable to proceed. Please contact your administrator",
|
||||
"error.unresolved.internet.name": "Your internet name cannot be resolved.",
|
||||
"firewall.close": "Firewall",
|
||||
"force.delete.domain.warning": "Warning: Choosing this option will cause the deletion of all child domains and all associated accounts and their resources.",
|
||||
|
||||
@ -66,7 +66,8 @@ router.beforeEach((to, from, next) => {
|
||||
.catch(() => {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: i18n.t('message.error.discovering.feature')
|
||||
description: i18n.t('message.error.discovering.feature'),
|
||||
duration: 0
|
||||
})
|
||||
store.dispatch('Logout').then(() => {
|
||||
next({ path: '/user/login', query: { redirect: to.fullPath } })
|
||||
|
||||
@ -19,6 +19,7 @@ import Cookies from 'js-cookie'
|
||||
import Vue from 'vue'
|
||||
import md5 from 'md5'
|
||||
import message from 'ant-design-vue/es/message'
|
||||
import notification from 'ant-design-vue/es/notification'
|
||||
import router from '@/router'
|
||||
import store from '@/store'
|
||||
import { login, logout, api } from '@/api'
|
||||
@ -112,6 +113,8 @@ const user = {
|
||||
commit('SET_LDAP', {})
|
||||
commit('SET_CLOUDIAN', {})
|
||||
|
||||
notification.destroy()
|
||||
|
||||
resolve()
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
@ -148,6 +151,8 @@ const user = {
|
||||
api('listZones', { listall: true }).then(json => {
|
||||
const zones = json.listzonesresponse.zone || []
|
||||
commit('SET_ZONES', zones)
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
api('listApis').then(response => {
|
||||
const apis = {}
|
||||
|
||||
@ -37,16 +37,29 @@ const err = (error) => {
|
||||
notification.error({ message: i18n.t('label.forbidden'), description: data.message })
|
||||
}
|
||||
if (response.status === 401) {
|
||||
if (response.config && response.config.params && ['listIdps'].includes(response.config.params.command)) {
|
||||
if (response.config && response.config.params && ['listIdps', 'cloudianIsEnabled'].includes(response.config.params.command)) {
|
||||
return
|
||||
}
|
||||
for (const key in response.data) {
|
||||
if (key.includes('response')) {
|
||||
if (response.data[key].errortext.includes('not available for user')) {
|
||||
notification.error({
|
||||
message: 'Error',
|
||||
description: response.data[key].errortext + ' ' + i18n.t('error.unable.to.proceed'),
|
||||
duration: 0
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
notification.error({
|
||||
message: i18n.t('label.unauthorized'),
|
||||
description: i18n.t('message.authorization.failed'),
|
||||
key: 'http-401'
|
||||
key: 'http-401',
|
||||
duration: 0
|
||||
})
|
||||
store.dispatch('Logout').then(() => {
|
||||
router.go(0)
|
||||
router.push({ path: '/user/login', query: { redirect: router.history.current.fullPath } })
|
||||
})
|
||||
}
|
||||
if (response.status === 404) {
|
||||
|
||||
@ -648,6 +648,10 @@ export default {
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
if ([401].includes(error.response.status)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Object.keys(this.searchParams).length > 0) {
|
||||
this.itemCount = 0
|
||||
this.items = []
|
||||
@ -658,13 +662,6 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
if ([401].includes(error.response.status)) {
|
||||
store.dispatch('Logout').then(() => {
|
||||
this.$router.push({ path: '/user/login', query: { redirect: this.$route.fullPath } })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.$notifyError(error)
|
||||
|
||||
if ([405].includes(error.response.status)) {
|
||||
@ -892,6 +889,9 @@ export default {
|
||||
api(action.api, params).then(json => {
|
||||
this.handleResponse(json, resourceName, action, false)
|
||||
}).catch(error => {
|
||||
if ([401].includes(error.response.status)) {
|
||||
return
|
||||
}
|
||||
this.$notifyError(error)
|
||||
})
|
||||
},
|
||||
@ -992,6 +992,10 @@ export default {
|
||||
}
|
||||
this.closeAction()
|
||||
}).catch(error => {
|
||||
if ([401].includes(error.response.status)) {
|
||||
return
|
||||
}
|
||||
|
||||
console.log(error)
|
||||
this.$notifyError(error)
|
||||
}).finally(f => {
|
||||
|
||||
@ -175,19 +175,16 @@ export default {
|
||||
this.resource = domains[0] || {}
|
||||
this.treeSelected = domains[0] || {}
|
||||
}).catch(error => {
|
||||
if ([401].includes(error.response.status)) {
|
||||
return
|
||||
}
|
||||
|
||||
this.$notification.error({
|
||||
message: this.$t('message.request.failed'),
|
||||
description: error.response.headers['x-description'],
|
||||
duration: 0
|
||||
})
|
||||
|
||||
if ([401].includes(error.response.status)) {
|
||||
store.dispatch('Logout').then(() => {
|
||||
this.$router.push({ path: '/user/login', query: { redirect: this.$route.fullPath } })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if ([405].includes(error.response.status)) {
|
||||
this.$router.push({ path: '/exception/403' })
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user